OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "platform.h" | 7 #include "platform.h" |
8 #include "cctest.h" | 8 #include "cctest.h" |
9 #include "diy-fp.h" | 9 #include "diy-fp.h" |
10 #include "double.h" | 10 #include "double.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 uint64_t max_double64 = V8_2PART_UINT64_C(0x7fefffff, ffffffff); | 195 uint64_t max_double64 = V8_2PART_UINT64_C(0x7fefffff, ffffffff); |
196 diy_fp = Double(max_double64).AsNormalizedDiyFp(); | 196 diy_fp = Double(max_double64).AsNormalizedDiyFp(); |
197 Double(max_double64).NormalizedBoundaries(&boundary_minus, &boundary_plus); | 197 Double(max_double64).NormalizedBoundaries(&boundary_minus, &boundary_plus); |
198 CHECK_EQ(diy_fp.e(), boundary_minus.e()); | 198 CHECK_EQ(diy_fp.e(), boundary_minus.e()); |
199 CHECK_EQ(diy_fp.e(), boundary_plus.e()); | 199 CHECK_EQ(diy_fp.e(), boundary_plus.e()); |
200 // max-value does not have a significand of the form 2^p (for some p). | 200 // max-value does not have a significand of the form 2^p (for some p). |
201 // Therefore its boundaries are at the same distance. | 201 // Therefore its boundaries are at the same distance. |
202 CHECK(diy_fp.f() - boundary_minus.f() == boundary_plus.f() - diy_fp.f()); | 202 CHECK(diy_fp.f() - boundary_minus.f() == boundary_plus.f() - diy_fp.f()); |
203 CHECK((1 << 10) == diy_fp.f() - boundary_minus.f()); // NOLINT | 203 CHECK((1 << 10) == diy_fp.f() - boundary_minus.f()); // NOLINT |
204 } | 204 } |
| 205 |
| 206 |
| 207 TEST(NextDouble) { |
| 208 CHECK_EQ(4e-324, Double(0.0).NextDouble()); |
| 209 CHECK_EQ(0.0, Double(-0.0).NextDouble()); |
| 210 CHECK_EQ(-0.0, Double(-4e-324).NextDouble()); |
| 211 Double d0(-4e-324); |
| 212 Double d1(d0.NextDouble()); |
| 213 Double d2(d1.NextDouble()); |
| 214 CHECK_EQ(-0.0, d1.value()); |
| 215 CHECK_EQ(0.0, d2.value()); |
| 216 CHECK_EQ(4e-324, d2.NextDouble()); |
| 217 CHECK_EQ(-1.7976931348623157e308, Double(-V8_INFINITY).NextDouble()); |
| 218 CHECK_EQ(V8_INFINITY, |
| 219 Double(V8_2PART_UINT64_C(0x7fefffff, ffffffff)).NextDouble()); |
| 220 } |
OLD | NEW |