Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: test/cctest/test-strtod.cc

Issue 4653003: Work around windows compiler bug. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bignum.h" 7 #include "bignum.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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 StrtodChar("1234567890123456789052345", 111)); 252 StrtodChar("1234567890123456789052345", 111));
253 CHECK_EQ(1234567890123456789052345e112, 253 CHECK_EQ(1234567890123456789052345e112,
254 StrtodChar("1234567890123456789052345", 112)); 254 StrtodChar("1234567890123456789052345", 112));
255 CHECK_EQ(1234567890123456789052345e113, 255 CHECK_EQ(1234567890123456789052345e113,
256 StrtodChar("1234567890123456789052345", 113)); 256 StrtodChar("1234567890123456789052345", 113));
257 CHECK_EQ(1234567890123456789052345e114, 257 CHECK_EQ(1234567890123456789052345e114,
258 StrtodChar("1234567890123456789052345", 114)); 258 StrtodChar("1234567890123456789052345", 114));
259 CHECK_EQ(1234567890123456789052345e115, 259 CHECK_EQ(1234567890123456789052345e115,
260 StrtodChar("1234567890123456789052345", 115)); 260 StrtodChar("1234567890123456789052345", 115));
261 261
262 // Boundary cases. 262 // Boundary cases. Boundaries themselves should round to even.
263 //
263 // 0x1FFFFFFFFFFFF * 2^3 = 72057594037927928 264 // 0x1FFFFFFFFFFFF * 2^3 = 72057594037927928
264 // next: 72057594037927936 265 // next: 72057594037927936
265 // boundary: 72057594037927932 266 // boundary: 72057594037927932 should round up.
266 CHECK_EQ(72057594037927928.0, StrtodChar("72057594037927928", 0)); 267 CHECK_EQ(72057594037927928.0, StrtodChar("72057594037927928", 0));
267 CHECK_EQ(72057594037927936.0, StrtodChar("72057594037927936", 0)); 268 CHECK_EQ(72057594037927936.0, StrtodChar("72057594037927936", 0));
268 CHECK_EQ(72057594037927936.0, StrtodChar("72057594037927932", 0)); 269 CHECK_EQ(72057594037927936.0, StrtodChar("72057594037927932", 0));
269 CHECK_EQ(72057594037927928.0, StrtodChar("7205759403792793199999", -5)); 270 CHECK_EQ(72057594037927928.0, StrtodChar("7205759403792793199999", -5));
270 CHECK_EQ(72057594037927936.0, StrtodChar("7205759403792793200001", -5)); 271 CHECK_EQ(72057594037927936.0, StrtodChar("7205759403792793200001", -5));
271 272
272 // 0x1FFFFFFFFFFFF * 2^10 = 9223372036854774784 273 // 0x1FFFFFFFFFFFF * 2^10 = 9223372036854774784
273 // next: 9223372036854775808 274 // next: 9223372036854775808
274 // boundary: 9223372036854775296 275 // boundary: 9223372036854775296 should round up.
275 CHECK_EQ(9223372036854774784.0, StrtodChar("9223372036854774784", 0)); 276 CHECK_EQ(9223372036854774784.0, StrtodChar("9223372036854774784", 0));
276 CHECK_EQ(9223372036854775808.0, StrtodChar("9223372036854775808", 0)); 277 CHECK_EQ(9223372036854775808.0, StrtodChar("9223372036854775808", 0));
277 CHECK_EQ(9223372036854775296.0, StrtodChar("9223372036854775296", 0)); 278 CHECK_EQ(9223372036854775808.0, StrtodChar("9223372036854775296", 0));
278 CHECK_EQ(9223372036854774784.0, StrtodChar("922337203685477529599999", -5)); 279 CHECK_EQ(9223372036854774784.0, StrtodChar("922337203685477529599999", -5));
279 CHECK_EQ(9223372036854775808.0, StrtodChar("922337203685477529600001", -5)); 280 CHECK_EQ(9223372036854775808.0, StrtodChar("922337203685477529600001", -5));
280 281
281 // 0x1FFFFFFFFFFFF * 2^50 = 10141204801825834086073718800384 282 // 0x1FFFFFFFFFFFF * 2^50 = 10141204801825834086073718800384
282 // next: 10141204801825835211973625643008 283 // next: 10141204801825835211973625643008
283 // boundary: 10141204801825834649023672221696 284 // boundary: 10141204801825834649023672221696 should round up.
284 CHECK_EQ(10141204801825834086073718800384.0, 285 CHECK_EQ(10141204801825834086073718800384.0,
285 StrtodChar("10141204801825834086073718800384", 0)); 286 StrtodChar("10141204801825834086073718800384", 0));
286 CHECK_EQ(10141204801825835211973625643008.0, 287 CHECK_EQ(10141204801825835211973625643008.0,
287 StrtodChar("10141204801825835211973625643008", 0)); 288 StrtodChar("10141204801825835211973625643008", 0));
288 CHECK_EQ(10141204801825834649023672221696.0, 289 CHECK_EQ(10141204801825835211973625643008.0,
289 StrtodChar("10141204801825834649023672221696", 0)); 290 StrtodChar("10141204801825834649023672221696", 0));
290 CHECK_EQ(10141204801825834086073718800384.0, 291 CHECK_EQ(10141204801825834086073718800384.0,
291 StrtodChar("1014120480182583464902367222169599999", -5)); 292 StrtodChar("1014120480182583464902367222169599999", -5));
292 CHECK_EQ(10141204801825835211973625643008.0, 293 CHECK_EQ(10141204801825835211973625643008.0,
293 StrtodChar("1014120480182583464902367222169600001", -5)); 294 StrtodChar("1014120480182583464902367222169600001", -5));
294 295
295 // 0x1FFFFFFFFFFFF * 2^99 = 5708990770823838890407843763683279797179383808 296 // 0x1FFFFFFFFFFFF * 2^99 = 5708990770823838890407843763683279797179383808
296 // next: 5708990770823839524233143877797980545530986496 297 // next: 5708990770823839524233143877797980545530986496
297 // boundary: 5708990770823839207320493820740630171355185152 298 // boundary: 5708990770823839207320493820740630171355185152
299 // The boundary should round up.
298 CHECK_EQ(5708990770823838890407843763683279797179383808.0, 300 CHECK_EQ(5708990770823838890407843763683279797179383808.0,
299 StrtodChar("5708990770823838890407843763683279797179383808", 0)); 301 StrtodChar("5708990770823838890407843763683279797179383808", 0));
300 CHECK_EQ(5708990770823839524233143877797980545530986496.0, 302 CHECK_EQ(5708990770823839524233143877797980545530986496.0,
301 StrtodChar("5708990770823839524233143877797980545530986496", 0)); 303 StrtodChar("5708990770823839524233143877797980545530986496", 0));
302 CHECK_EQ(5708990770823839207320493820740630171355185152.0, 304 CHECK_EQ(5708990770823839524233143877797980545530986496.0,
303 StrtodChar("5708990770823839207320493820740630171355185152", 0)); 305 StrtodChar("5708990770823839207320493820740630171355185152", 0));
304 CHECK_EQ(5708990770823838890407843763683279797179383808.0, 306 CHECK_EQ(5708990770823838890407843763683279797179383808.0,
305 StrtodChar("5708990770823839207320493820740630171355185151999", -3)); 307 StrtodChar("5708990770823839207320493820740630171355185151999", -3));
306 CHECK_EQ(5708990770823839524233143877797980545530986496.0, 308 CHECK_EQ(5708990770823839524233143877797980545530986496.0,
307 StrtodChar("5708990770823839207320493820740630171355185152001", -3)); 309 StrtodChar("5708990770823839207320493820740630171355185152001", -3));
308 } 310 }
309 311
310 312
311 static int CompareBignumToDiyFp(const Bignum& bignum_digits, 313 static int CompareBignumToDiyFp(const Bignum& bignum_digits,
312 int bignum_exponent, 314 int bignum_exponent,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 buffer[pos++] = random() % 10 + '0'; 408 buffer[pos++] = random() % 10 + '0';
407 } 409 }
408 int exponent = DeterministicRandom() % (308*2 + 1) - 308 - length; 410 int exponent = DeterministicRandom() % (308*2 + 1) - 308 - length;
409 buffer[pos] = '\0'; 411 buffer[pos] = '\0';
410 Vector<const char> vector(buffer, pos); 412 Vector<const char> vector(buffer, pos);
411 double strtod_result = Strtod(vector, exponent); 413 double strtod_result = Strtod(vector, exponent);
412 CHECK(CheckDouble(vector, exponent, strtod_result)); 414 CHECK(CheckDouble(vector, exponent, strtod_result));
413 } 415 }
414 } 416 }
415 } 417 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698