Lost variable accuracy in Simulation mode

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Lost variable accuracy in Simulation mode

Post by Jan Lichtenbelt »

Testing the accuracy of the Sinus and Cosinus values, see elsewhere, I found some accuracy loss of floating point variables ONLY IN THE SIMULATION mode.

A macro can return a floating point variable. If used the accuracy *) will be changed to 0.000001 (absolute). Or said it in a different way, the return floating point value of a macro will be rounded to 6 numbers after the decimal point. This happens only in the simulation mode, not when a microcontroller is used.

Be prepared!

Jan Lichtenbelt

*) Note. I do not know the accuray of floating point variables. Floating point variables use 4 bytes. As far as I know, the last byte is used for the exponential part and sign, the other 3 bytes are used for the number after the decimal point. That means the accuracy of floating point variables is 2^24.
Attachments
Accuracy of floating macro value.fcf
(8.5 KiB) Downloaded 253 times

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: Lost variable accuracy in Simulation mode

Post by Benj »

Hello Jan,

The float variables are indeed 4-bytes. I think the simulation does differ slightly from the physical hardware where floating point numbers are involved though I do not know the cause of this. I've added it to the bugs list anyway for us to look at and try to solve.

Post Reply