Post Reply 
FORTH for the PC-G850(V)(S)
12-07-2022, 03:07 AM
Post: #11
RE: FORTH for the PC-G850(V)(S)
(11-29-2022 07:56 PM)robve Wrote:  I may extend the library to support INF/NAN and banker's rounding to make it compliant with IEEE 754. Right now, the only observable difference is the rounding (lack thereof).

I rewrote part of the Z80 IEEE 754 math core today to add two proper IEEE 754 rounding modes to choose from (at compile time):
  • round to nearest, ties to even a.k.a. banker's rounding, typically used by libmath as the default rounding mode (C/C++, Python, Lua, Julia etc.)
  • round to nearest, ties to away
The Forth850 update will use round to nearest, ties to even. Correct rounding is applied to addition, subtraction, multiplication, division and all Forth floating point math functions (since they use these core routines.) The string input and output of floats was already properly rounding. The Z80 math library is 67 bytes longer for just a tad over 1K of portable Z80 code and does not suffer from performance degradation or other compromises, i.e. no memory accesses as everything is still kept in Z80 registers.

Adding INF/NAN is should actually be easy with some logic to test these special cases. I could make it an option. But I prefer to have exceptions in Forth to catch floating point overflow, division by zero etc. so signaling NaN and INF exceptions.

With internal proper round to nearest, ties to even the new sine plot is perfectly symmetric on close inspection:
[Image: IMG_5355.jpg]

A bit surprised myself that I was able to pull this off, as I was already using all Z80 registers Smile

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
FORTH for the PC-G850(V)(S) - robve - 11-06-2022, 01:56 PM
RE: FORTH for the PC-G850(V)(S) - robve - 11-08-2022, 09:23 PM
RE: FORTH for the PC-G850(V)(S) - Sukiari - 11-09-2022, 07:45 PM
RE: FORTH for the PC-G850(V)(S) - robve - 11-10-2022, 09:36 PM
RE: FORTH for the PC-G850(V)(S) - xerxes - 11-11-2022, 01:55 AM
RE: FORTH for the PC-G850(V)(S) - robve - 11-12-2022, 12:28 AM
RE: FORTH for the PC-G850(V)(S) - robve - 11-12-2022, 06:26 PM
RE: FORTH for the PC-G850(V)(S) - robve - 11-13-2022, 10:15 PM
RE: FORTH for the PC-G850(V)(S) - robve - 11-14-2022, 07:35 PM
RE: FORTH for the PC-G850(V)(S) - robve - 11-29-2022, 07:56 PM
RE: FORTH for the PC-G850(V)(S) - robve - 12-07-2022 03:07 AM
RE: FORTH for the PC-G850(V)(S) - robve - 01-01-2023, 05:45 PM
RE: FORTH for the PC-G850(V)(S) - F-73P - 01-03-2023, 03:32 AM
RE: FORTH for the PC-G850(V)(S) - robve - 01-03-2023, 06:57 PM
RE: FORTH for the PC-G850(V)(S) - F-73P - 01-05-2023, 07:52 AM
RE: FORTH for the PC-G850(V)(S) - robve - 05-20-2023, 11:11 PM
RE: FORTH for the PC-G850(V)(S) - robve - 07-31-2023, 01:53 AM



User(s) browsing this thread: 1 Guest(s)