WebKit / standards-positions

WebKit's positions on emerging web specifications
https://webkit.org/standards-positions/
240 stars 18 forks source link

JavaScript/TC39: Decimal: Exact decimal numbers #272

Open jessealama opened 8 months ago

jessealama commented 8 months ago

WebKittens

@msaboff @annevk

Title of the spec

Ecma TC39 Decimal Numbers

URL to the spec

https://github.com/tc39/proposal-decimal

URL to the spec's repository

https://github.com/tc39/proposal-decimal

Issue Tracker URL

https://github.com/tc39/proposal-decimal/issues

Explainer URL

No response

TAG Design Review URL

No response

Mozilla standards-positions issue URL

No response

WebKit Bugzilla URL

No response

Radar URL

No response

Description

The proposal is an extension of ECMAScript to support exact decimal (base-10) numbers. Decimals are exact representations of numbers that we are familiar with in daily life. In this setting, 1.3 would be handled as the mathematical value 1.3 rather than a base-2 approximation thereof. These numbers, and the need for operating on them faithfully, are widespread when handling money but also show up in handling all sorts of human-readable/writeable numeric values.

Our current thinking about decimals is that there would be a new object in the ECMAScript standard library (the name is TBD, but is likely to be Decimal or Decimal128). No new syntax or primitive data types would be added to ECMAScript. The underlying data model would be IEEE 754 Decimal128 floating-point decimals, where values use 128 bits. (This data model allows for up to 34 significant digits, with an exponent [power of ten] of +/- 6144.) The envisioned API would contain only basic arithmetic (addition, subtraction, multiplication, division), rounding, remainder, and comparison (less-than/equals/greater-than).

As of writing, the specification is at stage 1 in the Ecma TC39 process.