Fork me on GitHub
#clojure-nl
<
2019-12-08
>
Mno13:12:14

you could say it’s “Simple” 😏

eval202016:12:35

Might just be enough ;)

helios17:12:53

something weird i encountered

helios17:12:08

on my laptop (java 8):
(Math/pow 9 17)
=> 1.667718169966657E16

on a friend laptop (java 11):
(Math/pow 9 17)
1.6677181699666568E16

Lennart Buit20:12:52

Their reading is more correct to the actual 16677181699666569

Lennart Buit21:12:35

this is a nice can of worms you found btw

Lennart Buit21:12:40

Heres a class that (for a performance tradeoff) makes stronger guarantees about rounding: https://docs.oracle.com/javase/7/docs/api/java/lang/StrictMath.html

Lennart Buit21:12:30

I do wonder, is there an optimisation difference between 8/11 that - within the rules of floating point - produces a slightly different result

helios07:12:35

In practice, also first creating a BigInteger and then using .pow of that class also produces correct results (in this particular case). Here it was very suprising that number of digits differ between two different java versions. I am wondering how many "wrong" pieces of code will stop to work

helios07:12:21

Wrong because, at least in the case that i was looking at, having the java8 precision resulted in two errors which cancelled each other :man-facepalming: and of course that wasn't happening with java11. If you switch to exact math it's correct

helios07:12:57

FYI it was the checking whether 21897142587612075 is a Narcissistic number: http://mathworld.wolfram.com/NarcissisticNumber.html

Lennart Buit07:12:23

floating point is not meant to be exact, it is meant to give a pretty good estimate on a wide range of numbers 😛

Lennart Buit07:12:41

(I was fairly close to trying to dump generated machine code on Java 8/11, but decided that it was 11 o’clock and that was not beneficial to this working day)

helios08:12:47

Of course floating point should not be used for anything that precise.. but I have seen things... floats used to store MONEY...

helios08:12:45

Anyway, the surprise in my case was mostly that i wasn't aware of a change like that between 8 and 11. 😄

Lennart Buit20:12:10

not running a Pentium 1 is (s)he 😉