There is an intToStr method that can convert an int to a string:
import strutils
let myNum = 4
let s = intToStr(myNum)
echo s
Running this yields:
4
To convert a very small or very large value, you can use Nim's "toString" operator, $:
let num = 54322348923482347
let numStr = $num
echo numStr[1]
Running this yields:
4
If you want to print the value in a formatted string, you can use the strformat library:
import strformat
let myNum = 4573589373453485
let s = fmt"Value: {myNum}"
echo s
Running this yields:
Value: 4573589373453485
Leave a comment