Hello. I have problem with calculating float variables.
Sample:
float a = 5.2;
float result = a*a;
So result = 27.040000000000003!!!!
How to fix it?
Hello. I have problem with calculating float variables.
Sample:
float a = 5.2;
float result = a*a;
So result = 27.040000000000003!!!!
How to fix it?
Hi,
It is a common issue with javascript engine and the mathematical operations with float numbers, to solve the issue use the operation "prec"
for example if "a" is fieldname1 (to use the same fields' names in "Calculated Fields Form"), the equation would be:
prec(fieldname1*fieldname1,2)
If fieldname1 has the value 5.2 the operation result would be 27.04
Now, if you want a more precise result, use a bigger number as second parameter of "prec" operation, for example in:
prec(fieldname1*fieldname1,4)
the operation result would be 27.0400
Thanks!
This topic has been closed to new replies.