Format Float To String With Decimals
363,452 Views
-
| | | | --- | --- | | | # Returns Number converted to a string, truncated to Decimals places. | | | ToTruncatedString<public>(Number:float, Decimals:int):[]char= | | | var Str:[]char = ToString(Number) | | | if: | | | DotIndex := Str.Find['.'] | | | StopIndex := if (Decimals > 0) then Min(DotIndex+Decimals+1,Str.Length) else DotIndex | | | set Str = Str.Slice[0, StopIndex] | | | Str |Returns Number converted to a string, truncated to Decimals places.
ToTruncatedString<public>(Number:float, Decimals:int):[]char= var Str:[]char = ToString(Number) if: DotIndex := Str.Find['.'] StopIndex := if (Decimals > 0) then Min(DotIndex+Decimals+1,Str.Length) else DotIndex set Str = Str.Slice[0, StopIndex] Str
Copy full snippet(8 lines long)
Categories:
Purpose:
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.