60 function int2hwFloat (const i: LongInt) : hwFloat; inline; |
60 function int2hwFloat (const i: LongInt) : hwFloat; inline; |
61 function hwFloat2Float (const i: hwFloat) : extended; inline; |
61 function hwFloat2Float (const i: hwFloat) : extended; inline; |
62 |
62 |
63 // The implemented operators |
63 // The implemented operators |
64 |
64 |
|
65 operator = (const z1, z2: hwFloat) z:boolean; inline; |
65 operator + (const z1, z2: hwFloat) z : hwFloat; inline; |
66 operator + (const z1, z2: hwFloat) z : hwFloat; inline; |
66 operator - (const z1, z2: hwFloat) z : hwFloat; inline; |
67 operator - (const z1, z2: hwFloat) z : hwFloat; inline; |
67 operator - (const z1: hwFloat) z : hwFloat; inline; |
68 operator - (const z1: hwFloat) z : hwFloat; inline; |
68 |
69 |
69 operator * (const z1, z2: hwFloat) z : hwFloat; inline; |
70 operator * (const z1, z2: hwFloat) z : hwFloat; inline; |
86 function DistanceI(const dx, dy: LongInt): hwFloat; // Same as above for integer parameters. |
87 function DistanceI(const dx, dy: LongInt): hwFloat; // Same as above for integer parameters. |
87 function AngleSin(const Angle: Longword): hwFloat; |
88 function AngleSin(const Angle: Longword): hwFloat; |
88 function AngleCos(const Angle: Longword): hwFloat; |
89 function AngleCos(const Angle: Longword): hwFloat; |
89 function SignAs(const num, signum: hwFloat): hwFloat; inline; // Returns an hwFloat with the value of parameter num and the sign of signum. |
90 function SignAs(const num, signum: hwFloat): hwFloat; inline; // Returns an hwFloat with the value of parameter num and the sign of signum. |
90 function hwSign(r: hwFloat): LongInt; inline; // Returns an integer with value 1 and sign of parameter r. |
91 function hwSign(r: hwFloat): LongInt; inline; // Returns an integer with value 1 and sign of parameter r. |
91 |
92 function isZero(const z: hwFloat): boolean; inline; |
92 {$IFDEF FPC} |
93 {$IFDEF FPC} |
93 {$J-} |
94 {$J-} |
94 {$ENDIF} |
95 {$ENDIF} |
95 {$WARNINGS OFF} |
96 {$WARNINGS OFF} |
96 |
97 |
156 _25: hwFloat = (isNegative: false; QWordValue: 4294967296 * 25); |
157 _25: hwFloat = (isNegative: false; QWordValue: 4294967296 * 25); |
157 _30: hwFloat = (isNegative: false; QWordValue: 4294967296 * 30); |
158 _30: hwFloat = (isNegative: false; QWordValue: 4294967296 * 30); |
158 _40: hwFloat = (isNegative: false; QWordValue: 4294967296 * 40); |
159 _40: hwFloat = (isNegative: false; QWordValue: 4294967296 * 40); |
159 _50: hwFloat = (isNegative: false; QWordValue: 4294967296 * 50); |
160 _50: hwFloat = (isNegative: false; QWordValue: 4294967296 * 50); |
160 _70: hwFloat = (isNegative: false; QWordValue: 4294967296 * 70); |
161 _70: hwFloat = (isNegative: false; QWordValue: 4294967296 * 70); |
|
162 _90: hwFloat = (isNegative: false; QWordValue: 4294967296 * 90); |
161 _128: hwFloat = (isNegative: false; QWordValue: 4294967296 * 128); |
163 _128: hwFloat = (isNegative: false; QWordValue: 4294967296 * 128); |
|
164 _180: hwFloat = (isNegative: false; QWordValue: 4294967296 * 180); |
162 _250: hwFloat = (isNegative: false; QWordValue: 4294967296 * 250); |
165 _250: hwFloat = (isNegative: false; QWordValue: 4294967296 * 250); |
163 _256: hwFloat = (isNegative: false; QWordValue: 4294967296 * 256); |
166 _256: hwFloat = (isNegative: false; QWordValue: 4294967296 * 256); |
164 _300: hwFloat = (isNegative: false; QWordValue: 4294967296 * 300); |
167 _300: hwFloat = (isNegative: false; QWordValue: 4294967296 * 300); |
|
168 _360: hwFloat = (isNegative: false; QWordValue: 4294967296 * 360); |
165 _450: hwFloat = (isNegative: false; QWordValue: 4294967296 * 450); |
169 _450: hwFloat = (isNegative: false; QWordValue: 4294967296 * 450); |
166 _1000: hwFloat = (isNegative: false; QWordValue: 4294967296 * 1000); |
170 _1000: hwFloat = (isNegative: false; QWordValue: 4294967296 * 1000); |
167 _1024: hwFloat = (isNegative: false; QWordValue: 4294967296 * 1024); |
171 _1024: hwFloat = (isNegative: false; QWordValue: 4294967296 * 1024); |
168 _2048: hwFloat = (isNegative: false; QWordValue: 4294967296 * 2048); |
172 _2048: hwFloat = (isNegative: false; QWordValue: 4294967296 * 2048); |
169 _4096: hwFloat = (isNegative: false; QWordValue: 4294967296 * 4096); |
173 _4096: hwFloat = (isNegative: false; QWordValue: 4294967296 * 4096); |
194 function hwFloat2Float (const i: hwFloat) : extended; |
198 function hwFloat2Float (const i: hwFloat) : extended; |
195 begin |
199 begin |
196 hwFloat2Float:= i.QWordValue / $100000000; |
200 hwFloat2Float:= i.QWordValue / $100000000; |
197 if i.isNegative then hwFloat2Float:= -hwFloat2Float; |
201 if i.isNegative then hwFloat2Float:= -hwFloat2Float; |
198 end; |
202 end; |
|
203 |
|
204 operator = (const z1, z2: hwFloat) z:boolean; inline; |
|
205 begin |
|
206 z:= true; |
|
207 z:= z and (z1.isNegative = z2.isNegative); |
|
208 z:= z and (z1.QWordValue = z2.QWordValue); |
|
209 end; |
|
210 |
199 |
211 |
200 operator + (const z1, z2: hwFloat) z : hwFloat; |
212 operator + (const z1, z2: hwFloat) z : hwFloat; |
201 begin |
213 begin |
202 if z1.isNegative = z2.isNegative then |
214 if z1.isNegative = z2.isNegative then |
203 begin |
215 begin |