Reputation: 6775
I have a float, say 14.55e9
and I want to stringify it to "14550000000"
the most nimic, clean and performant way as possible.
For now I only could find something based on slicing:
$myFloat[0..$myFloat.find('.')]
The formatFloat
method from strutils
outputs "14550000000.0"
if you ask for precision=0
Upvotes: 0
Views: 698
Reputation: 1071
you can use
import json, math
var intvalue = int(math.floor( 14.55));
echo %*(intvalue);
EDIT: Sorry i posted some javascript code. Math is lowercase in Nim and JSON.stringify was from javascript
Upvotes: 1