OnixS C++ Tullett Prebon SURF Handler 1.6.1
API documentation
Loading...
Searching...
No Matches
Decimal.h
Go to the documentation of this file.
1/*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any
13 * part of this source code or associated reference material to any other location for further
14 * reproduction or redistribution, and any amendments to this copyright notice, are expressly
15 * prohibited.
16 *
17 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
18 * the terms of the Agreement is a violation of copyright law.
19 */
20
21#pragma once
22
23#include <OnixS/SURF/MarketData/Export.h>
24
25#include <iosfwd>
26#include <string>
27
28namespace OnixS { namespace SURF { namespace MarketData {
29
33struct ONIXS_TP_SURF_EXPORT Decimal
34{
36
37 Decimal(signed char);
38 Decimal(unsigned char);
39
40 Decimal(signed short);
41 Decimal(unsigned short);
42
43 Decimal(signed int);
44 Decimal(unsigned int);
45
46 Decimal(signed long long);
47 Decimal(unsigned long long);
48
49 Decimal(float value, size_t precision);
50
51 Decimal(signed long long mantissa, signed int exponent);
52
54 signed char sign,
55 unsigned long long mantissaHigh,
56 unsigned long long mantissaLow,
57 signed int exponent
58 );
59
60 Decimal(const std::string&);
61 Decimal(const char* buffer, size_t bufferSize);
62
63 Decimal(const Decimal& other);
64
65 signed long long mantissa() const;
66 void mantissa(signed long long);
67
68 signed int exponent() const;
69 void exponent(signed int);
70
71 bool toNumber(signed char& converted) const;
72 bool toNumber(unsigned char& converted) const;
73
74 bool toNumber(signed short& converted) const;
75 bool toNumber(unsigned short& converted) const;
76
77 bool toNumber(signed int& converted) const;
78 bool toNumber(unsigned int& converted) const;
79
80 bool toNumber(signed long long& converted) const;
81 bool toNumber(unsigned long long& converted) const;
82
83 bool toNumber(float& converted) const;
84 bool toNumber(double& converted) const;
85
86 operator signed int() const;
87 operator unsigned int() const;
88 operator signed long long() const;
89 operator unsigned long long() const;
90 operator double() const;
91
92 bool operator==(const Decimal& other) const;
93 bool operator!=(const Decimal& other) const;
94
95 Decimal& operator=(const Decimal& other);
96
97 Decimal& operator+=(const Decimal& other);
98 Decimal& operator-=(const Decimal& other);
99
100 Decimal& operator*=(const Decimal& other);
101 Decimal& operator/=(const Decimal& other);
102
103 std::string toString() const;
104
105private:
106 void unpack(
107 signed char* sign,
108 unsigned long long* mantissaHigh,
109 unsigned long long* mantissaLow,
110 signed int* exponent
111 ) const;
112
113private:
114 unsigned char bytes[16];
115};
116
117ONIXS_TP_SURF_EXPORT Decimal operator+(Decimal);
118ONIXS_TP_SURF_EXPORT Decimal operator-(Decimal);
119
120ONIXS_TP_SURF_EXPORT Decimal operator+(Decimal, Decimal);
121ONIXS_TP_SURF_EXPORT Decimal operator-(Decimal, Decimal);
122
123ONIXS_TP_SURF_EXPORT Decimal operator*(Decimal, Decimal);
124ONIXS_TP_SURF_EXPORT Decimal operator/(Decimal, Decimal);
125
126ONIXS_TP_SURF_EXPORT bool operator<(Decimal, Decimal);
127ONIXS_TP_SURF_EXPORT bool operator>(Decimal, Decimal);
128
129ONIXS_TP_SURF_EXPORT bool operator<=(Decimal, Decimal);
130ONIXS_TP_SURF_EXPORT bool operator>=(Decimal, Decimal);
131
132ONIXS_TP_SURF_EXPORT std::ostream& operator<<(std::ostream&, const Decimal&);
133
134}}} // namespace OnixS::SURF::MarketData
Decimal operator-(Decimal)
bool operator<(Decimal, Decimal)
Decimal operator*(Decimal, Decimal)
Decimal operator+(Decimal)
std::ostream & operator<<(std::ostream &, const Decimal &)
Decimal operator/(Decimal, Decimal)
bool operator>=(Decimal, Decimal)
bool operator<=(Decimal, Decimal)
bool operator>(Decimal, Decimal)
void mantissa(signed long long)
Decimal & operator=(const Decimal &other)
bool toNumber(signed int &converted) const
bool toNumber(unsigned short &converted) const
std::string toString() const
Decimal(signed char sign, unsigned long long mantissaHigh, unsigned long long mantissaLow, signed int exponent)
bool toNumber(signed long long &converted) const
bool toNumber(unsigned int &converted) const
Decimal & operator-=(const Decimal &other)
Decimal(const Decimal &other)
bool toNumber(signed short &converted) const
bool toNumber(double &converted) const
Decimal & operator*=(const Decimal &other)
Decimal(const char *buffer, size_t bufferSize)
bool operator==(const Decimal &other) const
Decimal & operator/=(const Decimal &other)
Decimal(signed long long mantissa, signed int exponent)
bool toNumber(unsigned long long &converted) const
Decimal(const std::string &)
bool toNumber(float &converted) const
Decimal & operator+=(const Decimal &other)
bool toNumber(unsigned char &converted) const
bool operator!=(const Decimal &other) const
bool toNumber(signed char &converted) const
signed long long mantissa() const
Decimal(float value, size_t precision)