whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
7.87k stars 2.58k forks source link

Proposal: More accurately notation in "rules for parsing floating-point number values". #3375

Open rh-KIMATA opened 6 years ago

rh-KIMATA commented 6 years ago

https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values

  1. Conversion: Let S be the set of finite IEEE 754 double-precision floating-point values except −0, but with two special values added: 21024 and −21024.
  2. Let rounded-value be the number in S that is closest to value, selecting the number with an even significand if there are two equally close values. (The two special values 21024 and −21024 are considered to have even significands for this purpose.)
  3. If rounded-value is 21024 or −21024, return an error.

But −21024 = 21024, because the power exponent is an even number.

"−21024" should be write "−(21024)" or "21024 * -1" for more accurately.

annevk commented 6 years ago

Per https://en.wikipedia.org/wiki/Order_of_operations this is correct, though apparently there are some programming languages that do it the other way around.

https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type uses the same notation as the HTML Standard.

I suppose we can make sure to clarify this as part of https://github.com/whatwg/infra/issues/87 with an example or some such, to explain that we mean it in the mathematical sense.

rh-KIMATA commented 6 years ago

Thanks for your comment.

Per https://en.wikipedia.org/wiki/Order_of_operations this is correct, though apparently there are some programming languages that do it the other way around.

Sorry, I was misunderstand it as "-32 = 9" in mathematically.

I suppose we can make sure to clarify this as part of whatwg/infra#87 with an example or some such, to explain that we mean it in the mathematical sense.

I agree to your plan.

domenic commented 6 years ago

I don't think we need to repeat mathematical notation in Infra; this is so well-established that I'd rather leave it to places like Wikipedia or math textbooks.

annevk commented 6 years ago

I was thinking that it might be worth an example due to the potential for confusion with some programming languages and folks copy-and-pasting these numbers mostly into programming languages and not Mathematica.

domenic commented 6 years ago

I'm not too worried because no programming languages use superscripts to denote exponentiation (except Mathematica).