ScummVM API documentation
dgGoogol.h
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef __dgGoogol__
23 #define __dgGoogol__
24 
25 
26 #include "dgStdafx.h"
27 #include "dgMemory.h"
28 #include "dgArray.h"
29 #include "dgVector.h"
30 
31 
32 
33 //#define DG_GOOGOL_SIZE 16
34 #define DG_GOOGOL_SIZE 4
35 
36 class dgGoogol {
37 public:
38  dgGoogol(void);
39  dgGoogol(dgFloat64 value);
40  ~dgGoogol(void);
41 
42  dgFloat64 GetAproximateValue() const;
43  void InitFloatFloat(dgFloat64 value);
44 
45  dgGoogol operator+ (const dgGoogol &A) const;
46  dgGoogol operator- (const dgGoogol &A) const;
47  dgGoogol operator* (const dgGoogol &A) const;
48  dgGoogol operator/ (const dgGoogol &A) const;
49 
50  dgGoogol operator+= (const dgGoogol &A);
51  dgGoogol operator-= (const dgGoogol &A);
52 
53  dgGoogol Floor() const;
54 
55 #ifdef _DEBUG
56  void Trace() const;
57  void ToString(char *const string) const;
58 #endif
59 
60 private:
61  void NegateMantissa(dgUnsigned64 *const mantissa) const;
62  void CopySignedMantissa(dgUnsigned64 *const mantissa) const;
63  dgInt32 NormalizeMantissa(dgUnsigned64 *const mantissa) const;
64  dgUnsigned64 CheckCarrier(dgUnsigned64 a, dgUnsigned64 b) const;
65  void ShiftRightMantissa(dgUnsigned64 *const mantissa, dgInt32 bits) const;
66 
67  dgInt32 LeadinZeros(dgUnsigned64 a) const;
68  void ExtendeMultiply(dgUnsigned64 a, dgUnsigned64 b, dgUnsigned64 &high, dgUnsigned64 &low) const;
69  void ScaleMantissa(dgUnsigned64 *const out, dgUnsigned64 scale) const;
70 
71  dgInt8 m_sign;
72  dgInt16 m_exponent;
73  dgUnsigned64 m_mantissa[DG_GOOGOL_SIZE];
74 };
75 
76 
77 class dgHugeVector: public dgTemplateVector<dgGoogol> {
78 public:
79  dgHugeVector()
81  }
82 
83  dgHugeVector(const dgBigVector &a)
84  : dgTemplateVector<dgGoogol>(dgGoogol(a.m_x), dgGoogol(a.m_y), dgGoogol(a.m_z), dgGoogol(a.m_w)) {
85  }
86 
89  }
90 
91  dgHugeVector(dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w)
92  : dgTemplateVector<dgGoogol>(x, y, z, w) {
93  }
94 
95  dgGoogol EvaluePlane(const dgHugeVector &point) const {
96  return (point % (*this)) + m_w;
97  }
98 
99 
100 
101 
102 #ifdef _DEBUG
103  void Trace() const {
104  m_x.Trace();
105  m_y.Trace();
106  m_z.Trace();
107  m_w.Trace();
108  dgTrace(("\n"));
109  }
110 #endif
111 };
112 
113 
114 #endif
Definition: dgGoogol.h:77
Definition: dgVector.h:34
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: dgGoogol.h:36
Definition: dgVector.h:104