Thursday, 11 June 2020

What I learned about Java from my 5-year old.

So, you're at home all day, because of all the COVID stuff, and in order to stay sane, you sometimes have to do things that are out of the ordinary.

Below is my attempt.


Thursday, 4 June 2020

The Dangers of Doubles

The problems with Doubles and Floats are already well documented, but sometimes we fall into the trap again.

In short, the representation of a real number1 in Float and Double is not precise2.

Normally, I am well aware of this limitation, but sometimes I get tripped up by already receiving Doubles and Floats as input.

In this case, it involved Geometrie coordinates, in doubles of course.

The following Unit Test shows the problem:

References

[1] Wikipedia - Real number
https://en.wikipedia.org/wiki/Real_number
[2] What Every Programmer Should Know About Floating-Point Arithmetic
https://floating-point-gui.de/