Jump to content



Photo
- - - - -

Floating Point Exceptions


  • Please log in to reply
6 replies to this topic

#1 AlephMobius

AlephMobius

    Casio Freak

  • Members
  • PipPipPipPip
  • 189 posts

  • Calculators:
    AFX 2.0+, TI-89, EL-9300C

Posted 24 July 2004 - 09:25 PM

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.

#2 SoftCalc

SoftCalc

    Casio Technician

  • Members
  • PipPipPipPipPipPip
  • 406 posts
  • Location:Portland, OR USA

  • Calculators:
    ClassPad 300 , AFX 2.0, HP-48/49/50, TI-89/92/Voyager, HP Expander, etc...

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 :P 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.

#3 huhn_m

huhn_m

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1957 posts
  • Gender:Male
  • Location:Germany / Dresden
  • Interests:Assembler(!!!)
    Computers and Programming
    Operating Systems
    Programmable Calculators
    Maths and everything arround it

  • Calculators:
    FX-82SX / AFX 2.0+ (ROM 1.03) / FX 1.0+ (ROM 1.03)

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!)

#4 AlephMobius

AlephMobius

    Casio Freak

  • Members
  • PipPipPipPip
  • 189 posts

  • Calculators:
    AFX 2.0+, TI-89, EL-9300C

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 Roeoender

Roeoender

    UCF ASM/C Programming Only Winner

  • [Legends]
  • PipPipPipPip
  • 273 posts
  • Gender:Male
  • Location:Gdynia, Poland
  • Interests:Technical University student (informatics)
    Interests:
    Sport climbing
    Orieenting (100km walk in 23h31min)
    C/Asm on calculators

    Dislike cars

  • Calculators:
    CASIO AFX 2.0 ROM 1.01, 10 countable fingers

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.

#6 AlephMobius

AlephMobius

    Casio Freak

  • Members
  • PipPipPipPip
  • 189 posts

  • Calculators:
    AFX 2.0+, TI-89, EL-9300C

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 mastermage

mastermage

    Casio Fan

  • Members
  • PipPip
  • 48 posts

  • Calculators:
    Graph100+ ROM 1.03, Dead Graph100 ROM 1.02, Classpad 300 0S 1.24

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