Binary representation [Software]
Hi Mittyri,
How nice, then it is also compiler-dependent...
The issue is that 0.05 cannot be represented accurately in a binary brain.
So, the compiler will need to deal with such a fraction and either round it up or round it down. Whatever it does, it can have downstream implications. In my case it implied that my simple naïve decimal logic (0.25 <=0.25) never evaluated to TRUE because it was not tested as such.
The solution could be to add e.g. 1e-8 to the righthand side. Dumb, but that's logic.
Computers suck.
❝ x=0.250000
❝ as it should be
❝
How nice, then it is also compiler-dependent...
The issue is that 0.05 cannot be represented accurately in a binary brain.
So, the compiler will need to deal with such a fraction and either round it up or round it down. Whatever it does, it can have downstream implications. In my case it implied that my simple naïve decimal logic (0.25 <=0.25) never evaluated to TRUE because it was not tested as such.
The solution could be to add e.g. 1e-8 to the righthand side. Dumb, but that's logic.
Computers suck.
—
Pass or fail!
ElMaestro
Pass or fail!
ElMaestro
Complete thread:
- Nervous ticks in C - a reminder of the cruel logic of logic ElMaestro 2018-03-15 10:24 [Software]
- Nervous ticks in C - a reminder of the cruel logic of logic mittyri 2018-03-15 11:55
- Binary representationElMaestro 2018-03-16 13:13
- bypassing eqaulity conditions mittyri 2018-03-17 18:12
- Binary representationElMaestro 2018-03-16 13:13
- Nervous ticks in C - a reminder of the cruel logic of logic nobody 2018-03-18 13:13
- Nervous ticks in C - a reminder of the cruel logic of logic ElMaestro 2018-03-19 09:44
- Nervous ticks in C - a reminder of the cruel logic of logic nobody 2018-03-22 08:56
- Check it out for yourself - Dissolution Bootstrap:-) ElMaestro 2018-03-22 17:16
- Check it out for yourself - Dissolution Bootstrap:-) Helmut 2018-03-22 18:50
- Check it out for yourself - Dissolution Bootstrap:-) ElMaestro 2018-03-22 19:04
- Check it out for yourself - Dissolution Bootstrap:-) Helmut 2018-03-22 22:22
- Check it out for yourself - Dissolution Bootstrap:-) ElMaestro 2018-03-22 19:04
- Check it out for yourself - Dissolution Bootstrap:-) Helmut 2018-03-22 18:50
- Check it out for yourself - Dissolution Bootstrap:-) ElMaestro 2018-03-22 17:16
- Nervous ticks in C - a reminder of the cruel logic of logic nobody 2018-03-22 08:56
- Nervous ticks in C - a reminder of the cruel logic of logic ElMaestro 2018-03-19 09:44
- Nervous ticks in C - a reminder of the cruel logic of logic mittyri 2018-03-15 11:55