FLOAT variable not working?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
imtiaz9
Posts: 15
Joined: Sat Aug 10, 2013 7:16 am
Been thanked: 1 time
Contact:

FLOAT variable not working?

Post by imtiaz9 »

Float variable is not working properly. the calculation say answer of 65000/1020= 63.7254 but variable show only 63.0000
Attachments
Flowcode1.fcf
(5.5 KiB) Downloaded 334 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: FLOAT variable not working?

Post 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.

Halcon0653
Posts: 8
Joined: Sun Apr 21, 2019 5:16 pm
Has thanked: 3 times
Contact:

Re: FLOAT variable not working?

Post by Halcon0653 »

Thanks!,
Same problem, same solution for me years later...

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: FLOAT variable not working?

Post 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.

Post Reply