Skip to content

Add ToSIString extension methods to BaseUnitExtensions#78

Open
Selene29 wants to merge 1 commit intoMadsKirkFoged:masterfrom
Selene29:tosistring
Open

Add ToSIString extension methods to BaseUnitExtensions#78
Selene29 wants to merge 1 commit intoMadsKirkFoged:masterfrom
Selene29:tosistring

Conversation

@Selene29
Copy link
Copy Markdown

@Selene29 Selene29 commented Mar 7, 2026

Summary

Adds two ToSIString() extension methods to BaseUnitExtensions that convert any BaseUnit to its SI representation and return a formatted string with the SI symbol.

  • ToSIString() — defaults to "g4" format
  • ToSIString(string format) — supports standard numeric formats plus V/S for significant digits display

Useful for frontend display where you want to show values in SI units regardless of the unit the value was created with.

Tests

9 tests covering default format, custom formats (f2, e2, v3), SI conversion from non-SI units, and various unit types (Length, Mass, Temperature, Pressure).

Adds two ToSIString() overloads that convert any BaseUnit to its SI
representation and return a formatted string with the SI symbol.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant