> it's a serious question,
Maybe. I hoped he would come back so that we would know for sure, but he did
not.
Well sometimes my answers may be wrong or bad, so it may be better to do not
answer at all and leave answers to the paid Nim devs, or at least native
english speakers. In am none of
@Stefan_Salewski @Nam > It`s a bit hard to believe that this is a serious
question because of > But maybe you missed that and have no CS experience. >
That is not a Nim issue, but occurs from representation of floats in the CPU
it's a serious question, no need to question about OP's CS
another option when in need for accuracy and to avoid rounding problem (like in
financial activities) is to use a Decimal library..
[http://net-informations.com/q/faq/float.html](http://net-informations.com/q/faq/float.html)
Wow! I didn't know of [https://float.exposed/](https://float.exposed/). Cool
website!
Maybe I'm wrong but I think the answer is fine, did not notice any arrogance
IMHO.
He just points out the docs first. It is really important to get used to docs
although no one likes them.
So called "CS degrees" are also very useful, you learn a ton of interesting
things there.
You can learn how float works in following web sites:
[https://float.exposed](https://float.exposed)/
[https://en.wikipedia.org/wiki/IEEE_754](https://en.wikipedia.org/wiki/IEEE_754)
The answer is really good but please respect that everyone here is learning and
some might not be from a CS background! I'm 15 and certainly not yet graduated
yet I code and love Nim. I guess it would be really nice if we leave arrogance
and so called "CS degrees" aside and talk Nim :)
`round` is Deprecated.
I think @adnan is right, in the round function output like 88.91 is
expected, but fmt should trim it to 2 decimals.
Your answer was nice but I think you it was equally helpful without:
> It's a bit hard to believe that this is a serious question because of..
and
> But maybe you missed that and have no CS experience.
I think most people would have stumbled across this in one programming language
or another.
[https://0.30004.com](https://0.30004.com)/
It`s a bit hard to believe that this is a serious question because of
[https://nim-lang.org/docs/math.html#round%2CT%2Cint](https://nim-lang.org/docs/math.html#round%2CT%2Cint)
But maybe you missed that and have no CS experience.
The basic fact is that we can not present each decimal number
I'm following "Nim basics" tutorial and stumbled to this case when I was trying
to convert in to cm:
import math,strformat
echo " in | cm"
echo "-"
for i in 1 .. 40:
echo fmt"{i:3}", " | ", round(float(i) * 2.54, 1)
Run
13 matches
Mail list logo