If you are going to use floating point numbers in any programming
language, Pharo included, you need to understand something about
them.�� Things like
��- the relevant precision is *fixed*; a Float in Pharo is *always*
���� a 64-bit IEEE floating-point number, which amongst other things
���� means (to a first approximation) 54 binary digits of precision.
���� It doesn't make the slightest amount of difference how many
���� decimal digits you use when writing the number, the precision
���� is *always* 54 binary digits.�� So you *did* get the precision
���� out of rounding that you put in, it's just that the precision
���� you put in was not what you thought it was.
��- almost all modern architectures offer BINARY arithmetic, not
���� decimal.�� (The main exceptions are IBM z/series and IBM POWER,
���� which offer binary *and* decimal.)�� Rounding a number to n
���� decimals is ALWAYS problematic using binary floats.�� This has
���� little or nothing to do with Smalltalk: it's the hardware.
���� (This is why you are advised to keep money in cents, not dollars.)
��- Again, this is NOT a language issue, it is a hardware issue.
���� IF you understand how binary floating point arithmetic works,
���� then the arithmetic you get in C or R or Smalltalk or Matlab
���� does not surprise you at all.
���� If you DON'T understand how binary floating point arithmetic works,
���� the hardware will *get* you sooner or later.
��- ScaledDecimal in Pharo didn't have to violate the principle of
���� least surprise, but it does, big time.
��- It would be really nice if Pharo offered true decimal arithmetic
���� as an option.�� There may already be a package for this.