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

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

FLOAT variable not working?

Postby imtiaz9 » Tue Oct 24, 2017 2:25 pm

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 66 times

User avatar
LeighM
Matrix Staff
Posts: 1889
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 446 times
Been thanked: 640 times
Contact:

Re: FLOAT variable not working?

Postby LeighM » Tue Oct 24, 2017 2:38 pm

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?

Postby Halcon0653 » Wed May 01, 2019 10:15 am

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

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

Re: FLOAT variable not working?

Postby Benj » Wed Oct 02, 2019 9:50 am

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.