Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions double-conversion/bignum-dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ enum BignumDtoaMode {
// 'requested_digits' digits after the decimal point. The produced digits
// might be too short in which case the caller has to fill the gaps with '0's.
// Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2.
// Halfway cases are rounded up. The call toFixed(0.15, 2) thus returns
// buffer="2", point=0.
// Halfway cases are rounded up. The call toFixed(0.25, 1) thus returns
// buffer="3", point=0.
// Note: the length of the returned buffer has no meaning wrt the significance
// of its digits. That is, just because it contains '0's does not mean that
// any other digit would not satisfy the internal identity requirement.
Expand Down
2 changes: 1 addition & 1 deletion double-conversion/double-to-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class DoubleToStringConverter {
// with '0's.
// Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2.
// Halfway cases are rounded towards +/-Infinity (away from 0). The call
// toFixed(0.15, 2) thus returns buffer="2", point=0.
// toFixed(0.25, 1) thus returns buffer="3", point=0.
// The returned buffer may contain digits that would be truncated from the
// shortest representation of the input.
// - PRECISION: produces 'requested_digits' where the first digit is not '0'.
Expand Down
2 changes: 1 addition & 1 deletion double-conversion/fixed-dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace double_conversion {
// Example: FastFixedDtoa(0.001, 5, ...) is allowed to return buffer = "1", and
// decimal_point = -2.
// Halfway cases are rounded towards +/-Infinity (away from 0). The call
// FastFixedDtoa(0.15, 2, ...) thus returns buffer = "2", decimal_point = 0.
// FastFixedDtoa(0.25, 1, ...) thus returns buffer = "3", decimal_point = 0.
// The returned buffer may contain digits that would be truncated from the
// shortest representation of the input.
//
Expand Down
6 changes: 6 additions & 0 deletions test/cctest/test-bignum-dtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ TEST(BignumDtoaVariousDoubles) {
CHECK_EQ("15", buffer.start());
CHECK_EQ(1, point);

BignumDtoa(0.25, BIGNUM_DTOA_FIXED, 1, buffer, &length, &point);
CHECK_GE(1, length - point);
TrimRepresentation(buffer);
CHECK_EQ("3", buffer.start());
CHECK_EQ(0, point);

double min_double = 5e-324;
BignumDtoa(min_double, BIGNUM_DTOA_SHORTEST, 0, buffer, &length, &point);
CHECK_EQ("5", buffer.start());
Expand Down
4 changes: 4 additions & 0 deletions test/cctest/test-fixed-dtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ TEST(FastFixedVariousDoubles) {
CHECK_EQ("1", buffer.start());
CHECK_EQ(1, point);

CHECK(FastFixedDtoa(0.25, 1, buffer, &length, &point));
CHECK_EQ("3", buffer.start());
CHECK_EQ(0, point);

CHECK(FastFixedDtoa(1e-23, 10, buffer, &length, &point));
CHECK_EQ("", buffer.start());
CHECK_EQ(-10, point);
Expand Down
Loading