OnixS C++ Tullett Prebon SURF Handler 1.6.1
Users' manual and 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
53 Decimal(signed char sign, unsigned long long mantissaHigh, unsigned long long mantissaLow, signed int exponent);
54
55 Decimal(const std::string&);
56 Decimal(const char* buffer, size_t bufferSize);
57
58 Decimal(const Decimal& other);
59
60 signed long long mantissa() const;
61 void mantissa(signed long long);
62
63 signed int exponent() const;
64 void exponent(signed int);
65
66 bool toNumber(signed char& converted) const;
67 bool toNumber(unsigned char& converted) const;
68
69 bool toNumber(signed short& converted) const;
70 bool toNumber(unsigned short& converted) const;
71
72 bool toNumber(signed int& converted) const;
73 bool toNumber(unsigned int& converted) const;
74
75 bool toNumber(signed long long& converted) const;
76 bool toNumber(unsigned long long& converted) const;
77
78 bool toNumber(float& converted) const;
79 bool toNumber(double& converted) const;
80
81 operator signed int() const;
82 operator unsigned int() const;
83 operator signed long long() const;
84 operator unsigned long long() const;
85 operator double() const;
86
87 bool operator==(const Decimal& other) const;
88 bool operator!=(const Decimal& other) const;
89
90 Decimal& operator=(const Decimal& other);
91
92 Decimal& operator+=(const Decimal& other);
93 Decimal& operator-=(const Decimal& other);
94
95 Decimal& operator*=(const Decimal& other);
96 Decimal& operator/=(const Decimal& other);
97
98 std::string toString() const;
99
100private:
101 void unpack(
102 signed char* sign,
103 unsigned long long* mantissaHigh,
104 unsigned long long* mantissaLow,
105 signed int* exponent
106 ) const;
107
108private:
109 unsigned char bytes[16];
110};
111
112ONIXS_TP_SURF_EXPORT Decimal operator+(Decimal);
113ONIXS_TP_SURF_EXPORT Decimal operator-(Decimal);
114
115ONIXS_TP_SURF_EXPORT Decimal operator+(Decimal, Decimal);
116ONIXS_TP_SURF_EXPORT Decimal operator-(Decimal, Decimal);
117
118ONIXS_TP_SURF_EXPORT Decimal operator*(Decimal, Decimal);
119ONIXS_TP_SURF_EXPORT Decimal operator/(Decimal, Decimal);
120
121ONIXS_TP_SURF_EXPORT bool operator<(Decimal, Decimal);
122ONIXS_TP_SURF_EXPORT bool operator>(Decimal, Decimal);
123
124ONIXS_TP_SURF_EXPORT bool operator<=(Decimal, Decimal);
125ONIXS_TP_SURF_EXPORT bool operator>=(Decimal, Decimal);
126
127ONIXS_TP_SURF_EXPORT std::ostream& operator<<(std::ostream&, const Decimal&);
128
129}}} // 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)