ToString abstract operation: least significant digit not uniquely determined

zer0uno

I'm reading the ECMAScript abstract operation ToString. In Step 5 (m is the number we want to convert to a string):

  1. Otherwise, let n, k, and s be integers such that k ≥ 1, 10^(k−1) ≤ s < 10^k, the Number value for s × 10^(nk) is m, and k is as small as possible. Note that k is the number of digits in the decimal representation of s, that s is not divisible by 10, and that the least significant digit of s is not necessarily uniquely determined by these criteria.

I can't figure out in which case the least significant digit of s would not be uniquely determined. Any example?

Bergi

The answer is - as always with floating point math - rounding at the edge of the available precision.

Let's take s = 7011750883285835, k=16 and some n (let's say n=0). Now determining m, we'll get the floating point number 0x3FE67006BD248487 (somewhere around 0.70117508832858355…). However, we could also have chosen s = 7011750883285836 and it would be equal to m as well.

The point is that if we had converted the double to decimal representation exactly, we would've gotten 0.701175088328583551167128007364. That is much longer than necessary (and implies higher precision than available), so the ToString algorithm specifies to make a decimal representation of m with the least amount of siginificant digits ("k is as small as possible") that still parses to the number m we want. Sometimes, we can both round up or round down to get that, and both ways are allowed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ToString abstract operation: least significant digit not uniquely determined

From Dev

Least significant non-zero digit of a factorial

From Dev

Add 1 to the least significant digit of a number in MATLAB

From Dev

In Python how to find the least significant digit

From Dev

Shift least significant digit out of hex sequence in JavaScript

From Dev

Why does Excel round the least significant digit when I paste in a large number?

From Dev

Clearing least significant bit

From Dev

Least significant bit mips

From Dev

To what extent are Applicative/Monad instances uniquely determined?

From Dev

Get most significant digit in python

From Dev

rounding through rule of significant digit

From Dev

Getting least significant bit in JavaScript

From Dev

Extraction of the least significant bit of a pixel

From Dev

Binary numbers in Java Least Significant

From Dev

Radix sort most significant first or least significant, which is faster?

From Dev

most significant v.s. least significant radix sort

From Dev

Rounding decimal when the last significant digit is 5

From Dev

Position of first significant digit after the decimal point

From Dev

Abstract Class and toString() method

From Dev

Index of second least significant set bit

From Dev

Where is least significant byte in C array

From Dev

Change the least significant bit (LSB) in java

From Dev

Overwriting least-significant bit in a Word

From Dev

How to shift left the least significant zero?

From Dev

How to write least significant bit into the buffer?

From Dev

How to Delete Least Significant Bit in Java?

From Dev

Change the least significant bit (LSB) in java

From Dev

fastest way to access the least significant bit of an integer?

From Dev

Efficient least significant set bit of "biginteger" class

Related Related

  1. 1

    ToString abstract operation: least significant digit not uniquely determined

  2. 2

    Least significant non-zero digit of a factorial

  3. 3

    Add 1 to the least significant digit of a number in MATLAB

  4. 4

    In Python how to find the least significant digit

  5. 5

    Shift least significant digit out of hex sequence in JavaScript

  6. 6

    Why does Excel round the least significant digit when I paste in a large number?

  7. 7

    Clearing least significant bit

  8. 8

    Least significant bit mips

  9. 9

    To what extent are Applicative/Monad instances uniquely determined?

  10. 10

    Get most significant digit in python

  11. 11

    rounding through rule of significant digit

  12. 12

    Getting least significant bit in JavaScript

  13. 13

    Extraction of the least significant bit of a pixel

  14. 14

    Binary numbers in Java Least Significant

  15. 15

    Radix sort most significant first or least significant, which is faster?

  16. 16

    most significant v.s. least significant radix sort

  17. 17

    Rounding decimal when the last significant digit is 5

  18. 18

    Position of first significant digit after the decimal point

  19. 19

    Abstract Class and toString() method

  20. 20

    Index of second least significant set bit

  21. 21

    Where is least significant byte in C array

  22. 22

    Change the least significant bit (LSB) in java

  23. 23

    Overwriting least-significant bit in a Word

  24. 24

    How to shift left the least significant zero?

  25. 25

    How to write least significant bit into the buffer?

  26. 26

    How to Delete Least Significant Bit in Java?

  27. 27

    Change the least significant bit (LSB) in java

  28. 28

    fastest way to access the least significant bit of an integer?

  29. 29

    Efficient least significant set bit of "biginteger" class

HotTag

Archive