I am writing a program for the AFX in Turbo C++. I am using matherr to catch math errors. When I run the program on the PC and I do something that should cause a domain error, matherr catches it on the PC but on the emulator or the real calculator it prints "Floating point error: Domain. Abnormal program termination." then exits the program. I tryed using signal but I haven't had any luck with that either. I can give example code if the answer isn't immediatley obvious. Thanks.

Floating Point Exceptions
Started by
AlephMobius
, Jul 24 2004 09:25 PM
6 replies to this topic
#1
Posted 24 July 2004 - 09:25 PM
#2
Posted 25 July 2004 - 05:47 AM
I'm not sure if the AFX handles floating point exceptions. This is something that needs to be supported by the BIOS and OS, which I'm guessing isn't.
The AFX uses BCDs internally, not floats or doubles.
The safest thing is to catch floating pont exceptions before they happen
You can always write wrapper functions for the common FPE culprits (like divide) that does something reasonable. If you really want you can even to a longjmp if you want similar behavior to an exception.
The AFX uses BCDs internally, not floats or doubles.
The safest thing is to catch floating pont exceptions before they happen

#3
Posted 25 July 2004 - 09:32 AM
In fact the AFX uses fixed point math since it has no math co processor.
TurboC includes its own math emulator in the programs (that makes
them slow btw. YOu should better use fixed point math!).
This emulator probably can't handle these exceptions since they are triggered by the software and not by the hardware (no FPU!)
TurboC includes its own math emulator in the programs (that makes
them slow btw. YOu should better use fixed point math!).
This emulator probably can't handle these exceptions since they are triggered by the software and not by the hardware (no FPU!)
#4
Posted 27 July 2004 - 02:18 AM
Yes, floating point is emulated but surely there is a way to catch errors. I don't really look forward to writing wrappers because I use just about all the math functions. It is emulated fast enough for my purposes. Thanks for the input

#5
Posted 27 July 2004 - 06:36 AM
BTW If your program will use *ANY* floating point math then it won't work on AFX with ROM 1.01 - it will just crash the calc. The reason for this is that FP emulation lib from borland probably takeovers an interrupt that is already used by the calc for something else.
I didn't try other compilers FPU emulation yet.
Anyway unless you are doing a math program then *FORGET* about floating point.
Roeoender.
I didn't try other compilers FPU emulation yet.
Anyway unless you are doing a math program then *FORGET* about floating point.
Roeoender.
#6
Posted 27 July 2004 - 05:11 PM
I am making an RPN interface similar to some HP calculators so floats (doubles actually) are what I need. Can someone with a ROM 1.01 AFX run some programs from different compilers I give you to see if they crash? What 16bit compilers are available other than Turbo C/C++ and Mars?
#7
Posted 27 July 2004 - 06:33 PM
Open Watcom and Visual C++ 1.5
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users