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?
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.
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?
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!