Mercurial > projects > ldc
comparison druntime/src/compiler/dmd/typeinfo/ti_real.d @ 759:d3eb054172f9
Added copy of druntime from DMD 2.020 modified for LDC.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 01:52:37 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
758:f04dde6e882c | 759:d3eb054172f9 |
---|---|
1 | |
2 // real | |
3 | |
4 module rt.typeinfo.ti_real; | |
5 | |
6 class TypeInfo_e : TypeInfo | |
7 { | |
8 override string toString() { return "real"; } | |
9 | |
10 override hash_t getHash(in void* p) | |
11 { | |
12 return (cast(uint *)p)[0] + (cast(uint *)p)[1] + (cast(ushort *)p)[4]; | |
13 } | |
14 | |
15 static equals_t _equals(real f1, real f2) | |
16 { | |
17 return f1 == f2 || | |
18 (f1 !<>= f1 && f2 !<>= f2); | |
19 } | |
20 | |
21 static int _compare(real d1, real d2) | |
22 { | |
23 if (d1 !<>= d2) // if either are NaN | |
24 { | |
25 if (d1 !<>= d1) | |
26 { if (d2 !<>= d2) | |
27 return 0; | |
28 return -1; | |
29 } | |
30 return 1; | |
31 } | |
32 return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1); | |
33 } | |
34 | |
35 override equals_t equals(in void* p1, in void* p2) | |
36 { | |
37 return _equals(*cast(real *)p1, *cast(real *)p2); | |
38 } | |
39 | |
40 override int compare(in void* p1, in void* p2) | |
41 { | |
42 return _compare(*cast(real *)p1, *cast(real *)p2); | |
43 } | |
44 | |
45 override size_t tsize() | |
46 { | |
47 return real.sizeof; | |
48 } | |
49 | |
50 override void swap(void *p1, void *p2) | |
51 { | |
52 real t; | |
53 | |
54 t = *cast(real *)p1; | |
55 *cast(real *)p1 = *cast(real *)p2; | |
56 *cast(real *)p2 = t; | |
57 } | |
58 | |
59 override void[] init() | |
60 { static real r; | |
61 | |
62 return (cast(real *)&r)[0 .. 1]; | |
63 } | |
64 } |