Jump to content
C4 Forums | Control4

Programming with float variable


Svdmerwe

Recommended Posts

  • 4 weeks later...

I've never had a need to use a float variable so far...

But I'd do some debugging.

first - obviously - check your variable is float, not int

second, try manually setting the value in the value box and see if it holds.

or, try a single decimal to see if that value holds and work up from there.

Link to comment
Share on other sites

Remove the "0" and see if it gives you result. If it does, there's a chance the system is processing the second command before actually executing the first - but a 500ms delay in there and see if it works (can try 100ms after confirming it works on 500)

Link to comment
Share on other sites

  • 4 weeks later...

I have found the following:

- assigning a float value to the float variable works, no problem example assigning 0.254 to TestFloatA variable of type float.

- the problem is with adding to that value:

I tested the following:

added 0.254 five times to TestFloatA (with an initial value of 0.254) - did it by manually executing a piece of code 5 times (pressing EXECUTE button)

the expected result should have been 1.524 but the result is 0

added 1.254 five times to TestFloatD (with an initial value of 0)

the expected result should have been 6.27 but the result is 5

Conclusion: it seems as if the value to the right of the decimal sign is ignored when adding (+) values

(Note: I have tried to use delays but it does not make a difference)

 

Link to comment
Share on other sites

My testing confirms the same problem.

You can programmatically set the float variable to a floating point value such as 2.954

However the 'Set to Random Value Between' and the '+' programming options in composer are not working.

I'm assuming it is not simply a display issue, as the 'Set to Value' is working fine and you can see the variable has a value with decimals.

Likely a bug where the developer has referenced the value as integer instead of float/double/decimal.

Probably need someone @ C4 like @Derrick Cain who has been active on the forums before to have a look, or push this to the right person.

 

Link to comment
Share on other sites

  • 3 weeks later...

I was going to enter a defect on this issue, but can't reproduce it on the upcoming 2.10.2 release.

I added the same 1.254 value 5x times, and came up with the correct result (6.27).

I tried the random between 0 and 100, and got 85.377, and a different value (again, with 3 digits precision) when I executed it again.

I don't have a timeframe or schedule for when it will release, but it appears this has already been addressed in 2.10.2.

Thanks for bringing it up.

RyanE

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.