Mercurial > projects > ldc
comparison runtime/internal/typeinfo/ti_double.d @ 443:44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Reworked the LLVMDC specific pragmas.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Fri, 01 Aug 2008 00:32:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
442:76078c8ab5b9 | 443:44f08170f4ef |
---|---|
1 | |
2 // double | |
3 | |
4 module typeinfo.ti_double; | |
5 | |
6 class TypeInfo_d : TypeInfo | |
7 { | |
8 char[] toString() { return "double"; } | |
9 | |
10 hash_t getHash(void *p) | |
11 { | |
12 return (cast(uint *)p)[0] + (cast(uint *)p)[1]; | |
13 } | |
14 | |
15 static int _equals(double f1, double f2) | |
16 { | |
17 return f1 == f2 || | |
18 (f1 !<>= f1 && f2 !<>= f2); | |
19 } | |
20 | |
21 static int _compare(double d1, double 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 int equals(void *p1, void *p2) | |
36 { | |
37 return _equals(*cast(double *)p1, *cast(double *)p2); | |
38 } | |
39 | |
40 int compare(void *p1, void *p2) | |
41 { | |
42 return _compare(*cast(double *)p1, *cast(double *)p2); | |
43 } | |
44 | |
45 size_t tsize() | |
46 { | |
47 return double.sizeof; | |
48 } | |
49 | |
50 void swap(void *p1, void *p2) | |
51 { | |
52 double t; | |
53 | |
54 t = *cast(double *)p1; | |
55 *cast(double *)p1 = *cast(double *)p2; | |
56 *cast(double *)p2 = t; | |
57 } | |
58 | |
59 void[] init() | |
60 { static double r; | |
61 | |
62 return (cast(double *)&r)[0 .. 1]; | |
63 } | |
64 } | |
65 |