Values for numeric literals

Cameron McCormack cam at
Thu Jun 18 23:24:18 PDT 2009


I sent a mail a while ago asking about the rounding specified for the
mathematical value of a NumericLiteral.

I didn’t get a reply, so I thought I might ping the list again.

My reading of 7.8.3 (in the ES5 draft spec as well as ES3) is that
numeric literals with a certain number of significant digits can result
in two possible Number values.  With this statement:

  x = 1.23451234512345123457

the 7 should be the 21st significant digit, so the Number value assigned
to x can be either 1.2345123451234512345 or 1.2345123451234512346.  Is
that correct?  Why give a choice about what number value is used?  What
about with hex numeric literals?  Also, “incrementing the literal at the
20th significant digit position” doesn’t sound precise enough.

Why have this rounding method for NumericLiterals that is different from
the rounding method used in the definition of “the number value of x” in
section 8.5?

For the curious, I ask this because I’m wondering whether I should be
doing something like the rounding in ES5 7.8.3 in Web IDL, where I
define what the value of a float terminal is:



Cameron McCormack ≝

More information about the es5-discuss mailing list