1

I'm just curious about the result of the following multiplication :

(* 2.14 5.0) ==> 10.700001

Why this remaining '1' at the end of the result ? Thank you !

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
manzerbredes
  • 310
  • 2
  • 13
  • 2.14 isn't exact in base 2 float. It's `10.0*01000111101011100001` with the part after * repeating infinitely. A float has 65 base2 so you only get `10.001000111101011100001010001111010111000010100011110101110000101` which is the source of the error. You can write it as a ratio `(* 214/100 5) ; ==> 107/10`. You have this in base 10 too. eg `1/3` is `0,*3` and if you use a limited significant digits you end up with a lower value than it really is. [DEC64](http://dec64.com/) as a numeric type in our programming languages would have fixed this. – Sylwester Jan 21 '18 at 21:22
  • A double float only has 54 bits of precision (53 explicit), I suspect you were a column out on your keyboard. A single float (typical for `single-float` and default CL float type) has 24 bits of precision (23 explicit). – Dan Robertson Jan 21 '18 at 22:55
  • 1
    Try also `(* (/ 214 100) 5)` for comparison – coredump Jan 22 '18 at 10:37

0 Answers0