Mercurial > mm7
comparison OurMath.h @ 2040:98a727563cc3
Слияние
author | Ritor1 |
---|---|
date | Fri, 22 Nov 2013 13:54:38 +0600 |
parents | 7a9477135943 |
children | 8e9be4fa33a8 |
comparison
equal
deleted
inserted
replaced
2039:6971834a0d81 | 2040:98a727563cc3 |
---|---|
1 #pragma once | |
2 | |
3 #include <cassert> | |
4 #include <limits> | |
5 | |
6 /* 186 */ | |
7 #pragma pack(push, 1) | |
8 struct stru193_math | |
9 { | |
10 stru193_math(); | |
11 int Cos(int angle); | |
12 unsigned int Atan2(int x, int y); | |
13 int Sin(int angle); | |
14 | |
15 int pTanTable[520]; | |
16 int pCosTable[520]; | |
17 int pInvCosTable[520]; | |
18 static const unsigned int uIntegerPi = 1024; | |
19 static const unsigned int uIntegerHalfPi = 512; | |
20 static const unsigned int uIntegerDoublePi = 2048; | |
21 static const unsigned int uDoublePiMask = 2047; | |
22 static const unsigned int uPiMask = 1023; | |
23 static const unsigned int uHalfPiMask = 511; | |
24 }; | |
25 #pragma pack(pop) | |
26 | |
27 __int64 fixpoint_mul(int, int); | |
28 __int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2); | |
29 __int64 fixpoint_div(int, int); | |
30 __int64 fixpoint_sub_unknown(int, int); | |
31 int fixpoint_from_float(float value); | |
32 int fixpoint_from_int(int lhv, int rhv); | |
33 | |
34 template <typename FloatType> | |
35 inline int bankersRounding( | |
36 const FloatType& value | |
37 ) { | |
38 assert("Method unsupported for this type" && false); | |
39 return value; | |
40 } | |
41 | |
42 template<> inline int bankersRounding<float>(const float& inValue) | |
43 { | |
44 union Cast | |
45 { | |
46 double d; | |
47 long l; | |
48 }; | |
49 volatile Cast c; | |
50 c.d = inValue + 6755399441055744.0; | |
51 return c.l; | |
52 } | |
53 | |
54 #pragma push_macro("max") | |
55 #undef max | |
56 template<> inline int bankersRounding<double>(const double& inValue) | |
57 { | |
58 double maxValue = std::numeric_limits<int>::max(); | |
59 assert(maxValue - 6755399441055744.0 >= inValue); | |
60 union Cast | |
61 { | |
62 double d; | |
63 long l; | |
64 }; | |
65 volatile Cast c; | |
66 c.d = inValue + 6755399441055744.0; | |
67 return c.l; | |
68 } | |
69 #pragma pop_macro("max") | |
70 | |
71 extern struct stru193_math *stru_5C6E00; |