HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SYS_Decimal128.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SYS_Decimal128.h (SYS Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __SYS_DECIMAL128_H_INCLUDED__
12 #define __SYS_DECIMAL128_H_INCLUDED__
13 
14 #include "SYS_API.h"
15 #ifndef __SYS_Types__
16 #error This file must be included from SYS_Types.h
17 #endif
18 
19 #include <iosfwd>
20 
21 
22 /// Decimal128 floating point class (IEEE 754-2008)
24 {
25 public:
26  /// Default constructor, leaves value uninitialized
28 
29  explicit SYS_Decimal128(int32 v);
30  explicit SYS_Decimal128(uint32 v);
31  explicit SYS_Decimal128(fpreal32 v);
32  explicit SYS_Decimal128(fpreal64 v);
33  explicit SYS_Decimal128(const char *str);
34 
35  /// Conversion to other type
36  /// @{
37  operator int32() const;
38  operator uint32() const;
39  operator fpreal32() const;
40  operator fpreal64() const;
41  /// @}
42 
43  /// Round to nearest integer, 0.6 rounds up
44  int32 roundedInt() const;
45 
46  /// Unary minus
47  SYS_Decimal128 operator-() const;
48 
49  /// Assignment
50  /// @{
51  SYS_Decimal128& operator=(int32 v);
52  SYS_Decimal128& operator=(uint32 v);
53  SYS_Decimal128& operator=(fpreal32 v);
54  SYS_Decimal128& operator=(fpreal64 v);
55  /// @}
56 
57  /// Arithmetic Assignment
58  /// @{
59  SYS_Decimal128& operator+=(const SYS_Decimal128 &v);
60  SYS_Decimal128& operator-=(const SYS_Decimal128 &v);
62  SYS_Decimal128& operator/=(const SYS_Decimal128 &v);
63  /// @}
64 
65  /// Set to zero
66  void zero();
67 
68  /// Classification
69  /// @{
70  bool isCanonical() const;
71  bool isFinite() const;
72  bool isInfinite() const;
73  bool isInteger() const;
74  bool isNan() const;
75  bool isNegative() const;
76  bool isNormal() const;
77  bool isPositive() const;
78  bool isZero() const;
79  /// @}
80 
81  /// Determine number of significant digits
82  uint numDigits() const;
83 
84  /// Comparison Operators
85  /// @{
86  bool operator==(const SYS_Decimal128 &v) const;
87  bool operator!=(const SYS_Decimal128 &v) const
88  { return !(*this == v); }
89  bool operator<(const SYS_Decimal128 &v) const;
90  bool operator<=(const SYS_Decimal128 &v) const;
91  bool operator>(const SYS_Decimal128 &v) const;
92  bool operator>=(const SYS_Decimal128 &v) const;
93  /// @}
94 
95  /// Maximum string length+1
96  static const int NUMBUF = 43;
97 
98  /// Conversion to string, buffer must contain at least NUMBUF bytes
99  void toString(char *str) const;
100 
101  /// Conversion from string
102  void fromString(const char *str);
103 
104 private:
105  uint8 myValue[16];
106 };
107 
108 /// Binary arithmetic operators
109 /// @{
111  const SYS_Decimal128 &y);
113  const SYS_Decimal128 &y);
115  const SYS_Decimal128 &y);
117  const SYS_Decimal128 &y);
118 /// @}
119 
120 /// Stream I/O
121 /// @{
122 SYS_API std::ostream& operator<<(std::ostream &os, const SYS_Decimal128 &v);
123 SYS_API std::istream& operator>>(std::istream &is, SYS_Decimal128 &v);
124 /// @}
125 
126 /// String formatting
127 /// @{
128 SYS_API size_t format(char *buffer, size_t buffer_size, const SYS_Decimal128 &v);
129 /// @}
130 
131 #endif // __SYS_DECIMAL128_H_INCLUDED__
Mat3< typename promote< S, T >::type > operator*(S scalar, const Mat3< T > &m)
Returns M, where for .
Definition: Mat3.h:615
bool operator<=(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:376
SYS_API size_t format(char *buffer, size_t buffer_size, const SYS_Decimal128 &v)
SYS_API SYS_Decimal128 operator/(const SYS_Decimal128 &x, const SYS_Decimal128 &y)
const GLdouble * v
Definition: glcorearb.h:836
SYS_API std::ostream & operator<<(std::ostream &os, const SYS_Decimal128 &v)
Mat3< typename promote< T0, T1 >::type > operator+(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Returns M, where for .
Definition: Mat3.h:631
GLint y
Definition: glcorearb.h:102
bool isNegative(const Type &x)
Return true if x is less than zero.
Definition: Math.h:354
GLuint buffer
Definition: glcorearb.h:659
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
bool isFinite(const Type &x)
Return true if x is finite.
Definition: Math.h:363
Mat3< typename promote< T0, T1 >::type > operator-(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Returns M, where for .
Definition: Mat3.h:641
double fpreal64
Definition: SYS_Types.h:185
bool operator>=(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:386
bool operator!=(const SYS_Decimal128 &v) const
bool operator<(const GU_TetrahedronFacet &a, const GU_TetrahedronFacet &b)
int int32
Definition: SYS_Types.h:28
const Vec2< S > & operator*=(Vec2< S > &v, const Matrix33< T > &m)
Definition: ImathMatrix.h:3330
unsigned int uint
Definition: SYS_Types.h:33
bool operator>(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:381
unsigned char uint8
Definition: SYS_Types.h:25
png_infop png_bytep png_size_t buffer_size
Definition: png.h:2124
Decimal128 floating point class (IEEE 754-2008)
GLint GLenum GLint x
Definition: glcorearb.h:408
SYS_API std::istream & operator>>(std::istream &is, SYS_Decimal128 &v)
#define SYS_API
Definition: SYS_API.h:11
SYS_API SYS_Decimal128 operator-(const SYS_Decimal128 &x, const SYS_Decimal128 &y)
float fpreal32
Definition: SYS_Types.h:184
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:324
unsigned int uint32
Definition: SYS_Types.h:29