Scientific formatting, was: Garbled characters in Charts

Why do we occasionally see such garbled characters in programs?AB0004

Hi,

It depends on the format specifier for the populated value of a variable. And it can be corrected by using the right specifier as per the need.

Note 1
The % Format Specifiers

1 Like

My problem,

I think that value ... e-43 must be less than 1

so I have used the

IF ( T > 1 ) { // T -> I want to display values
PlotText( "" + T , i , H(i) , colorWhite ) ;
}

To filter these useless values,
But they still appear from time to time

the code like this

AB0011

9.444752e-43 is NOT negative number. It is just small (close to zero) positive number.
9.444752e-43 is scientific notation and means

9.444752 × 10 -43

Scientific notation explained here: https://en.wikipedia.org/wiki/Scientific_notation

If you want to avoid small number to display text like this you have to FORMAT numbers, using StrFormat or NumToStr like this:

T = 12e-43; // small number
i = 0; // to avoid syntax errors (normally you would place code below in a loop)
PlotText( "" + StrFormat("%.2f", T) , i , H(i) , colorWhite ) ; // will display 0.00
4 Likes