Division problem
I am trying to get a decimal number into a float. So I did this
Y=fdiv(itof((int)14278),itof((int)10000));
Which should result in 1.4278. Instead I get 1.42779994.
I know there is some rounding error when dealing with floats but I didn't think it was this bad. Am I doing something wrong?
Did you use a recent checkout, ie after i changed the binary format to IEEE754? That might be more accurate, before that it used just two bytes for the mantissa.
That said, there may well be other problems with the rounding and int/float conversion - i did not do any extensive tests.
Looks like I grabbed it 3 days before the last update. I'll pull and try again.
If you are adventurous, you could also try https://github.com/mrdudz/cc65/tree/fptest (see https://github.com/cc65/cc65/pull/1777 )
I love a good adventure. The latest update did not change the result, so I'll give fptest a try.
The problem is likely the crude way i am converting from int to float, basically just truncating the mantissa instead of rounding it.