MadsKirkFoged / EngineeringUnits

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

ToString() without scientific notation #60

Closed mbrown-dlb closed 1 month ago

mbrown-dlb commented 1 month 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 1 month 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