Page 1 of 1
FLOAT variable not working?
Posted: Tue Oct 24, 2017 2:25 pm
by imtiaz9
Float variable is not working properly. the calculation say answer of 65000/1020= 63.7254 but variable show only 63.0000
Re: FLOAT variable not working?
Posted: Tue Oct 24, 2017 2:38 pm
by LeighM
Hi,
That's because TOTAL and ADC are integers, not floats, hence TOTAL/ADC is still an integer, which gets converted to a float value.
You need to make TOTAL and ADC float variables.
Re: FLOAT variable not working?
Posted: Wed May 01, 2019 10:15 am
by Halcon0653
Thanks!,
Same problem, same solution for me years later...
Re: FLOAT variable not working?
Posted: Wed Oct 02, 2019 9:50 am
by Benj
Try this instead and you should get the right result.
65000.0/1020.0
Adding the decimal point forces the values to be floats and hence use the floating point maths library. Otherwise you will be using the integer maths library for speed and efficiency.