GteIEEEBinary16.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
11 
12 namespace gte
13 {
14 
15 struct _Float16 { int16_t _dummy; };
16 
17 class IEEEBinary16 : public IEEEBinary<_Float16, uint16_t, 16, 11>
18 {
19 public:
20  // Construction and destruction. The base class destructor is hidden, but
21  // this is safe because there are no side effects of the destruction.
22  ~IEEEBinary16();
23  IEEEBinary16(); // uninitialized
24  IEEEBinary16(IEEEBinary16 const& object);
25  IEEEBinary16(float number);
26  IEEEBinary16(double number);
27  IEEEBinary16(uint16_t encoding);
28 
29  // Implicit conversions.
30  operator float() const;
31  operator double() const;
32 
33  // Assignment.
34  IEEEBinary16& operator=(IEEEBinary16 const& object);
35 
36  // Comparison.
37  bool operator==(IEEEBinary16 const& object) const;
38  bool operator!=(IEEEBinary16 const& object) const;
39  bool operator< (IEEEBinary16 const& object) const;
40  bool operator<=(IEEEBinary16 const& object) const;
41  bool operator> (IEEEBinary16 const& object) const;
42  bool operator>=(IEEEBinary16 const& object) const;
43 
44 private:
45  // Support for conversions between encodings.
46  enum
47  {
48  F32_NUM_ENCODING_BITS = 32,
49  F32_NUM_TRAILING_BITS = 23,
50  F32_EXPONENT_BIAS = 127,
51  F32_MAX_BIASED_EXPONENT = 255,
52  F32_SIGN_MASK = 0x80000000,
53  F32_NOT_SIGN_MASK = 0x7FFFFFFF,
54  F32_BIASED_EXPONENT_MASK = 0x7F800000,
55  F32_TRAILING_MASK = 0x007FFFFF,
56  F16_AVR_MIN_SUBNORMAL_ZERO = 0x33000000,
57  F16_MIN_SUBNORMAL = 0x33800000,
58  F16_MIN_NORMAL = 0x38800000,
59  F16_MAX_NORMAL = 0x477FE000,
60  F16_AVR_MAX_NORMAL_INFINITY = 0x477FF000,
61  DIFF_NUM_ENCODING_BITS = 16,
62  DIFF_NUM_TRAILING_BITS = 13,
63  DIFF_PAYLOAD_SHIFT = 13,
64  INT_PART_MASK = 0x007FE000,
65  FRC_PART_MASK = 0x00001FFF,
66  FRC_HALF = 0x00001000
67  };
68 
69  static uint16_t Convert32To16(uint32_t encoding);
70  static uint32_t Convert16To32(uint16_t encoding);
71 };
72 
73 // Arithmetic operations (high-precision).
79 float operator+(IEEEBinary16 x, float y);
80 float operator-(IEEEBinary16 x, float y);
81 float operator*(IEEEBinary16 x, float y);
82 float operator/(IEEEBinary16 x, float y);
83 float operator+(float x, IEEEBinary16 y);
84 float operator-(float x, IEEEBinary16 y);
85 float operator*(float x, IEEEBinary16 y);
86 float operator/(float x, IEEEBinary16 y);
87 
88 // Arithmetic updates.
97 
98 }
DualQuaternion< Real > & operator*=(DualQuaternion< Real > &d, Real scalar)
GLint GLenum GLint x
Definition: glcorearb.h:404
DualQuaternion< Real > operator+(DualQuaternion< Real > const &d)
DualQuaternion< Real > & operator-=(DualQuaternion< Real > &d0, DualQuaternion< Real > const &d1)
DualQuaternion< Real > operator-(DualQuaternion< Real > const &d)
DualQuaternion< Real > & operator+=(DualQuaternion< Real > &d0, DualQuaternion< Real > const &d1)
DualQuaternion< Real > & operator/=(DualQuaternion< Real > &d, Real scalar)
Vector4< float > operator*(Transform const &M, Vector4< float > const &V)
GLint y
Definition: glcorearb.h:98
DualQuaternion< Real > operator/(DualQuaternion< Real > const &d, Real scalar)


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00