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

Side by Side Diff: src/strtod.cc

Issue 9578011: Fix double-rounding in strtod for MinGW. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 months 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 int exponent = 0; 168 int exponent = 0;
169 *result = DiyFp(significand, exponent); 169 *result = DiyFp(significand, exponent);
170 *remaining_decimals = buffer.length() - read_digits; 170 *remaining_decimals = buffer.length() - read_digits;
171 } 171 }
172 } 172 }
173 173
174 174
175 static bool DoubleStrtod(Vector<const char> trimmed, 175 static bool DoubleStrtod(Vector<const char> trimmed,
176 int exponent, 176 int exponent,
177 double* result) { 177 double* result) {
178 #if (defined(V8_TARGET_ARCH_IA32) || defined(USE_SIMULATOR)) && !defined(WIN32) 178 #if (defined(V8_TARGET_ARCH_IA32) || defined(USE_SIMULATOR)) \
179 && !defined(_MSC_VER)
179 // On x86 the floating-point stack can be 64 or 80 bits wide. If it is 180 // On x86 the floating-point stack can be 64 or 80 bits wide. If it is
180 // 80 bits wide (as is the case on Linux) then double-rounding occurs and the 181 // 80 bits wide (as is the case on Linux) then double-rounding occurs and the
181 // result is not accurate. 182 // result is not accurate.
182 // We know that Windows32 uses 64 bits and is therefore accurate. 183 // We know that Windows32 with MSVC, unlike with MinGW32, uses 64 bits and is
183 // Note that the ARM simulator is compiled for 32bits. It therefore exhibits 184 // therefore accurate.
184 // the same problem. 185 // Note that the ARM and MIPS simulators are compiled for 32bits. They
186 // therefore exhibit the same problem.
185 return false; 187 return false;
186 #endif 188 #endif
187 if (trimmed.length() <= kMaxExactDoubleIntegerDecimalDigits) { 189 if (trimmed.length() <= kMaxExactDoubleIntegerDecimalDigits) {
188 int read_digits; 190 int read_digits;
189 // The trimmed input fits into a double. 191 // The trimmed input fits into a double.
190 // If the 10^exponent (resp. 10^-exponent) fits into a double too then we 192 // If the 10^exponent (resp. 10^-exponent) fits into a double too then we
191 // can compute the result-double simply by multiplying (resp. dividing) the 193 // can compute the result-double simply by multiplying (resp. dividing) the
192 // two numbers. 194 // two numbers.
193 // This is possible because IEEE guarantees that floating-point operations 195 // This is possible because IEEE guarantees that floating-point operations
194 // return the best possible approximation. 196 // return the best possible approximation.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 433
432 double guess; 434 double guess;
433 if (DoubleStrtod(trimmed, exponent, &guess) || 435 if (DoubleStrtod(trimmed, exponent, &guess) ||
434 DiyFpStrtod(trimmed, exponent, &guess)) { 436 DiyFpStrtod(trimmed, exponent, &guess)) {
435 return guess; 437 return guess;
436 } 438 }
437 return BignumStrtod(trimmed, exponent, guess); 439 return BignumStrtod(trimmed, exponent, guess);
438 } 440 }
439 441
440 } } // namespace v8::internal 442 } } // namespace v8::internal
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