Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std/[strutils, strformat]
- proc roundfloat_str(fval: SomeFloat): string =
- strip(&"{fval:.0f}", leading=false, chars={'.'})
- proc floatStr(fval: SomeFloat): string =
- strip(&"{fval:f}", leading=false, chars={'.', '0'})
- echo &"{123.45:.0f}" # 123.
- echo roundfloat_str(123.45) # 123
- echo floatStr(123.45) # 123.45
- echo floatStr(123.0) # 123
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement