3 ms·
> a value in binary, a decimal places value, whatever odd logic there is required to hide the leaky abstraction. Ironically, this is a much better description
by dahfizz 4y ago
> a value in binary, a decimal places value, whatever odd logic there is required to hide the leaky abstraction.
Ironically, this is a much better description of `decimal` than of `float`.
IEEE float math is done in hardware. It is "one value in binary" that is added, subtracted, multiplied, etc etc with electric circuits.
The decimal abstraction requires manually keeping track of the number of significant digits, converting back and forth so that two different decimals can be added / multiplied, etc etc. There's a lot more that has to happen besides asking the CPU to do a single operation.
- ClumsyPilot 4y agoI do hope we will get a hardware implementation of decimal now that chipmakers dont k ow what to do with the extra transistors and keep coming up with new vector instructions, that most developers dont k ow how to ise and most languages don't even supoort
- dahfizz 4y agoWhich decimal? Fixed point, or floating point? Should the numerator and denominator be given the same bit width? How do you deal with overflow and underflow? Its easy to think of "decimal" as one thing because every language provides a library called `decimal`, but there are a million subtle decisions and tradeoffs to make when choosing one standard binary representation. Most languages don't have a binary representation at all, and implement `decimal` as a high level abstraction with regular integers.
- ClumsyPilot 4y agoPick a solution and make a decision just like it was done with every other format. IEEae has defined one, I believe it was mentioned above
- int_19h 4y agoWe managed to standardize on a single binary floating point representation in practice, and even if it's not perfect, the benefit from such standardization makes it worthwhile.