Commit ad605a1b authored by floitschV8@gmail.com's avatar floitschV8@gmail.com

Fix assumptions in DoubleToFixed.

By luck two errors cancelled each other out.

Review URL: http://codereview.chromium.org/4135014

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5760 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 97cb0061
...@@ -816,7 +816,7 @@ const char* IntToCString(int n, Vector<char> buffer) { ...@@ -816,7 +816,7 @@ const char* IntToCString(int n, Vector<char> buffer) {
char* DoubleToFixedCString(double value, int f) { char* DoubleToFixedCString(double value, int f) {
const int kMaxDigitsBeforePoint = 20; const int kMaxDigitsBeforePoint = 21;
const double kFirstNonFixed = 1e21; const double kFirstNonFixed = 1e21;
const int kMaxDigitsAfterPoint = 20; const int kMaxDigitsAfterPoint = 20;
ASSERT(f >= 0); ASSERT(f >= 0);
...@@ -840,9 +840,9 @@ char* DoubleToFixedCString(double value, int f) { ...@@ -840,9 +840,9 @@ char* DoubleToFixedCString(double value, int f) {
// Find a sufficiently precise decimal representation of n. // Find a sufficiently precise decimal representation of n.
int decimal_point; int decimal_point;
int sign; int sign;
// Add space for the '.' and the '\0' byte. // Add space for the '\0' byte.
const int kDecimalRepCapacity = const int kDecimalRepCapacity =
kMaxDigitsBeforePoint + kMaxDigitsAfterPoint + 2; kMaxDigitsBeforePoint + kMaxDigitsAfterPoint + 1;
char decimal_rep[kDecimalRepCapacity]; char decimal_rep[kDecimalRepCapacity];
int decimal_rep_length; int decimal_rep_length;
bool status = DoubleToAscii(value, DTOA_FIXED, f, bool status = DoubleToAscii(value, DTOA_FIXED, f,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment