News for hackers. Stuff that matters.
Re:Stage 3 Proposal: Array.prototype.at by Aardwolf on Wednesday June 02, 2021 @12:37PM (#27370778)
For financial makes sense, but science should be independent of numerical base?
Re:Stage 3 Proposal: Array.prototype.at by ihuman on Wednesday June 02, 2021 @01:12PM (#27371268)
I think the issue isn't the base, but that Javascript stores all numbers as 64-bit floats.
Re:Stage 3 Proposal: Array.prototype.at by dragonwriter on Wednesday June 02, 2021 @02:12PM (#27372042)
The decimal proposal is a vague enough that it is unclear if it would improve on that; if it was arbitrary-precision decimals, that would be an improvement. If it is limited precision but better than Number (seems unlikely), it would be an improvement. If it is limited precision but not better range/precision than Number, just decimal rather than binary floating point, its probably not an improvement. The proposal is vague enough that any of those would fit.
Re:Stage 3 Proposal: Array.prototype.at by dfabulich on Wednesday June 02, 2021 @01:33PM (#27371576)
JS has BigInt now. You can kinda fake BigDecimal with it, but none of the built-in operators will work.
Re:Stage 3 Proposal: Array.prototype.at by runarberg on Wednesday June 02, 2021 @03:22PM (#27372867)
How do you fake BigDecimal with BigInt? My immediate intuition would have a 3-tuple (a, b, c) which would construct the decimal with a representing the numbers before the decimal separator, b the number of zeroes immediately after the decimal separator, and c the numbers after the zeroes. e.g. 1.000054 would be represented as `[1n, 4n, 54n]` and 3.14159 as `[3n, 0n, 14159n]`.

Is there a better way?

Re:Stage 3 Proposal: Array.prototype.at by lbussell on Wednesday June 02, 2021 @03:59PM (#27373349)
What about a 2-tuple with two numbers, one being the BigInt and one being the exponent. So 1.000054 would be (1000054, -6) = 1000054*10^(-6).

Yours is probably more space efficient though.

Re:Stage 3 Proposal: Array.prototype.at by nine_k on Thursday June 03, 2021 @11:57AM (#27383283)
This is basically floating-point.

IEEE 754, BTW, allows for 10-based floats, but IDK if anybody uses it.

Re:Stage 3 Proposal: Array.prototype.at by wizzwizz4 on Wednesday June 02, 2021 @07:15PM (#27375196)
Yours is more space-efficient for real-world numbers.