echo(x * z )
the compiler complains: Error: type mismatch: got (int, uint16)
Is it impossible mixing ints and uints?
Then, another question: echo(7/3 ) gives: 2.3333333333333335e+000
how can i get: 2.333333 with the precision i want?
Thx - Regards.
It is possible to mix different types if you cast one to another:
echo(x * int(z))
To format floats you can use the formatFloat proc from the strutils module:
import strutils
echo(formatFloat(7/3, ffDecimal, 6))
Some people like to create their own template/inline alias to shorten that (ff or something like that) to avoid having to pass the same arguments over and over.