Precision issule about the float in scrpit/shader

Hello!

I pass some parameters in float format from C# script to the shader. I load the number from a text file, most of the number is in exponential format. The precision was terribly lost in the procedure:

float a = float.Parse(line, System.Globalization.NumberStyles.Float );

line is a string.

For example, the data loaded from the text is -1.86666E-008. It will become -1.86666E-08 after the parsing!

I have no idea how to avoid it.

Isn’t -008 the same as -08, just with an extra preceding 0?

As in, it’s still simply -8.

Yes you are right.

I found the things went wrong are not the numbers go with exponential, but 2 “integer” numbers stored in float. They will be corrected if I directly assign the value, yet go wrong if I load them from text. Need to figure it out.

Thank you for reminding!

Yet I still found something about precision.

Originally I define those floating number (with exponential) in shader, then move them to C# script. The result was indeed different and the ones in C# got better precision.