194 views
in GUI Development by

Hi,

I find that on the WebGL platform, the floating number will become very long whereas the prototype only reserve few digit.

Is there any way to avoid this issue?

Thanks

   

 

John

1 Answer

0 votes
by
Hello John,

the outputs should be equal in both cases. Can you provide the code snippet how the number is formatted?

Best regards

Paul Banach
by

Hi Paul,

Here is the code, it gets the float temperature and simply add a "℃".

Could it be the browser setting? The WebGL profile was working normally during prototyping, the problem only appear when I put the WebGL code to a web server, and run it on Chrome.

 

by

Hello John,

you used the most generic version of the string() instant constructor. Its behavior in fact may differ between the targets. In case of WebGL it always displays the 6 digits after the period sign. In other cases it displays up to 6 digits. We have to verify whether this different behavior was desired or whether it is error. Nevertheless, the results of the conversion are not useful in a GUI application because of the limitation to 6 digits after the period sign. The version of string() instant constructor is thus used mostly to print numbers during debugging or test.

To trustworthy format the floating point numbers in the GUI application I would recommend other version of the string() constructor where the number of digits after the period sign can be specified explicitly. See the form 9 in the chater Instant constructors: string(). For example, to always have 1 digit after the period sign:

PowerTemp.String = string( power, 0, 1 ) + "°C";

Does it solve the issue?

Best regards

Paul Banach

by
Hi Paul,

Thank you very much, it is clear now, problem is solved.

 

John

Embedded Wizard Website | Privacy Policy | Imprint

...