MadsKirkFoged / EngineeringUnits

Working with units made easy with automatic unit-check and converting between units
MIT License
42 stars 11 forks source link

ToString() without scientific notation #60

Closed mbrown-dlb closed 3 months ago

mbrown-dlb commented 4 months ago

If a unit has a large value (>10000) the .ToString() automatically displays the value with scientific notation. Is there a way to override this behavior?

MadsKirkFoged commented 3 months ago

You can use the formats: https://github.com/MadsKirkFoged/EngineeringUnits?tab=readme-ov-file#what-are-my-options-for-outputting-to-a-string

Pressure LargeNumber = Pressure.FromBar(1000000);

string PrintOut = LargeNumber.ToString();  //1e+06 bar
string PrintOut2 = LargeNumber.ToString("S7"); //1000000 bar
string PrintOut3 = LargeNumber.ToString("G7"); //1000000 bar