in Embedded Wizard Studio by

    I am using EW 11.0 and recently noticed that when I declare a Device property in float and assign a default value 0.0000001, it works fine in the PC simulation, but when embedded code was generated (for imxRT1062), the XXXDeviceClass__Init was showing it 0.000000f! It's an issue for any value <0.000001f. Is it something to do with 32bit floating point representation?

When I edit the XXXDeviceClass__Init function manually in the embedded code, it works fine!

How can I assign a default value in exponential form?  

Thanks & Regards,


1 Answer

0 votes

Hello Rajani,

according to our bug trace records, floating point literals are truncated to 9 digits after the period sign - when evaluating the numbers. Later, when the numbers are generated in C code, they are truncated again to 6 digits after the period sign.

This is an error in Embedded Wizard. We have fixed the problem already for the upcoming version 12.00 we are actually working on. For older version you need a workaround or a dedicated patch.

The simplest workaround would be to avoid the floating point literals < 0.000001. This is of course not always possible. Second workaround would be to store the floating point literals in native code as demonstrated below. This will work, however, in target system only:

var float someValue; /* = 0.0000000001 does not work here */

// To correctly initialize the variable with a small value
// use 'native' code section. This will work in the target
// system only. Not in Prototyper.
$if !$prototyper
  native ( someValue )
    someValue = 0.0000000001f;

// ... use the value now

If none of the workarounds works for you, you can contact us via support@embedded-wizard.de for a patch.

Best regards

Paul Banach 

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint