LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 | 6 |
7 #ifdef GOARCH_arm | 7 static» uint64» uvnan» » = 0x7FF8000000000001ULL; |
8 // Use signaling NaN on ARM because at least on VFPv2 in | |
9 // ARM1136JF-S, quiet NaN are not preserved across conversion | |
10 static» uint64» uvnan» » = 0x7FF8000000000000ULL; | |
11 #else | |
12 static» uint64» uvnan» » = 0x7FF0000000000001ULL; | |
13 #endif | |
14 static uint64 uvinf = 0x7FF0000000000000ULL; | 8 static uint64 uvinf = 0x7FF0000000000000ULL; |
15 static uint64 uvneginf = 0xFFF0000000000000ULL; | 9 static uint64 uvneginf = 0xFFF0000000000000ULL; |
16 | 10 |
17 uint32 | 11 uint32 |
18 runtime·float32tobits(float32 f) | 12 runtime·float32tobits(float32 f) |
19 { | 13 { |
20 // The obvious cast-and-pointer code is technically | 14 // The obvious cast-and-pointer code is technically |
21 // not valid, and gcc miscompiles it. Use a union instead. | 15 // not valid, and gcc miscompiles it. Use a union instead. |
22 union { | 16 union { |
23 float32 f; | 17 float32 f; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 /* | 164 /* |
171 * Keep the top 11+e bits; clear the rest. | 165 * Keep the top 11+e bits; clear the rest. |
172 */ | 166 */ |
173 if(e <= 64-11) | 167 if(e <= 64-11) |
174 x &= ~(((uint64)1 << (64LL-11LL-e))-1); | 168 x &= ~(((uint64)1 << (64LL-11LL-e))-1); |
175 dd = runtime·float64frombits(x); | 169 dd = runtime·float64frombits(x); |
176 *ip = dd; | 170 *ip = dd; |
177 return d - dd; | 171 return d - dd; |
178 } | 172 } |
179 | 173 |
LEFT | RIGHT |