I have a calculated field which looks something like this:
1.0 * value_today - value_tomorrow * 1.0
value_today = 0.00000000051231231
value_tomorrow = 0.00000000051231231
But my result is -0.9999999999999999
How can i make my result = 0 instead?
I have a calculated field which looks something like this:
1.0 * value_today - value_tomorrow * 1.0
value_today = 0.00000000051231231
value_tomorrow = 0.00000000051231231
But my result is -0.9999999999999999
How can i make my result = 0 instead?
This is one of the quirks of floating point numbers in computers… unfortunately with such low resolution you can hit such precision errors.
If your figures are always with 17 decimal places, you can try changing the calculation as below to try to force the datasource to work with integers instead
( decimalToInt(value_today * 100000000000000000) - decimalToInt(value_tomorrow * 100000000000000000))
/
100000000000000000
Thank you! It works! I tried limiting the decimal places for both the values and it seems that works too.