Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@190c0f01a6] [MERGE #3635 @xiaoyinl] Num…
Browse files Browse the repository at this point in the history
…bers up to 10^21 shouldn't be displayed exponentially (Fixes #2751)

Merge pull request #3635 from xiaoyinl:num_exp

The spec section 7.1.12.1 requires that if a number's base 10 logarithm is <= 21, then it shouldn't use exponential notation when it's converted to String. The original code checks if the base 2 logarithm of the number is <= 60.

This fixes #2751.
  • Loading branch information
chakrabot authored and kfarnung committed Jan 9, 2018
1 parent f9d4dea commit cd8844b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@ BOOL Js::NumberUtilities::FNonZeroFiniteDblToStr(double dbl, _In_range_(2, 36) i
maxOutDigits = g_rgcchSig[radix];
__analysis_assume(maxOutDigits > 0);

if (wExp2 < -60 || wExp2 > 60)
if (dbl < 1e-21 || dbl > 1e+21)
{
// Use exponential notation. Get the exponent and normalize.
if (cbitDigit != 0)
Expand Down
8 changes: 4 additions & 4 deletions deps/chakrashim/core/test/Number/toString_3.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ n.toPrecision(20): 0.0000000000000000000
Test: 1e21
n.toString(): 1e+21
n.toString(10): 1e+21
n.toString(8): 1.5432711533427365(e+23)
n.toString(2): 1.101100011010111001001101011011100010111011110101(e+69)
n.toString(16): 3.635c9adc5dea(e+17)
n.toString(25): 1.1l259oooooof(e+15)
n.toString(8): 154327115334273650000000
n.toString(2): 1101100011010111001001101011011100010111011110101000000000000000000000
n.toString(16): 3635c9adc5dea00000
n.toString(25): 11l259ooooooo5ie
n.toFixed(): 1e+21
n.toFixed(0): 1e+21
n.toFixed(2): 1e+21
Expand Down

0 comments on commit cd8844b

Please sign in to comment.