Page 1 of 1

Floating Point Math

Posted: Sat Jul 20, 2019 9:56 am
by Smartmultienergy
Hi, trying to compare 2 floating point numbers to generate an on/off output

byte = float_eq(float, float) Compares two floating point numbers to see if they are equal
byte = float_ge(float, float) Compares two floating point numbers to see if they are greater then or equal
byte = float_gt(float, float) Compares two floating point numbers to see if they are greater then
byte = float_le(float, float) Compares two floating point numbers to see if they are less then or equal
byte = float_lt(float, float) Compares two floating point numbers to see if they are less the

Seem to be battling with the syntax, byte 0 - 255? So if they are equal for example is the byte output 255 and if unequal, byte output 0?

Re: Floating Point Math

Posted: Sat Jul 20, 2019 6:37 pm
by Jan Lichtenbelt
Hi Smartmultienergy

The result of a comparision will be in general a boolean instead of byte.

boolean= float_eq(float, float)
The boolean will be true or false (with values 1 and 0 respectively)

If you use byte= float_eq(float, float), byte will also be 1 or 0.

kind regards

Jan

Re: Floating Point Math

Posted: Mon Jul 22, 2019 1:02 pm
by Benj
Hello,

In Flowcode 8 you can use the decision icon directly with floats.

For example.

floatA = floatB

The float compare functions are now legacy and were designed as workarounds for the BoostC compiler floating point issues. Note they will still work with the new XC compiler.