jrpn icon indicating copy to clipboard operation
jrpn copied to clipboard

Floating point: Doing all internal math in decimal would be a more faithful simulation

Open zathras opened this issue 1 year ago • 2 comments

I don't have any plans to do this now, but as noted in #74, doing the mathematical operations internally in binary floating point and rounding to a 10-digit decimal mantissa can lead to some counter-intuitive behavior at the margins.

Doing all the math myself in decimal floating point is certainly doable, and any performance impact would be totally negligible. That would be a moderately significant undertaking. Kind of fun, mind you -- actually implementing tan and sqrt and y^x and all the rest from the ground up would be a fun project; I might even give it a whirl some day.

zathras avatar Jan 28 '24 18:01 zathras

Fully agree that this is enhancement with negligible impact. Still impressed and happy with the excellent level of the simulation. Many thanks. KR P

pane avatar Jan 28 '24 19:01 pane

I think I'll leave this issue open, as a collecting point if other folks find other places where it's worth it to convert to decimal math. I think #78 is the low hanging fruit, but maybe there are others?

zathras avatar Mar 02 '24 18:03 zathras

Implementing decimal multiplication and division improved the fidelity of rounding behavior, at least in a few areas I was able to spot. I was surprised at how far I was able to go with just add, subtract, multiply and divide being done in decimal floating point. For things like sqrt and trig functions, any benefit of decimal FP seems nonexistent; any rounding differences would, AFAIK, be nearly undetectable (except the special cases like cos(90 degrees) that are already handled).

I think it's fair to call this resolved, with this putback: d89456c

zathras avatar Sep 02 '24 17:09 zathras

As you stated, if someone needs the exact match, the ROM emulator is only the way to go. Some glitches and special cases is difficult to recognize without knowing all internal special massaging. I am also very impressed how faithful already previous versions are. Is the decimal multiplication and division already included in 2.1.15.2 or will they be in 2.1.16?

Good job, thank you. KR P

pane avatar Sep 03 '24 11:09 pane

2.1.16, which I'm planning to release in beta on Android and Linux today or tomorrow. I'll probably put the beta on the web too.

zathras avatar Sep 03 '24 15:09 zathras

Published in 2.1.16

zathras avatar Oct 04 '24 16:10 zathras