Mail Archives: djgpp/1995/08/20/06:16:24
On Sun, 13 Aug 1995, Emil Wataralov wrote:
> Be aware for following problem with djgpp's printf command.
> _doprnt engine, crashes program with Floating point exception,
> if trying to print FP NaNs (Not A Numbers). This happens with
> all printf, sprintf, fprintf, vsprintf...
>
> Rajiv, I've fixed this by checking FP numbers for NaNs before calling
> printf. Mail me if you need the code or try V2.0, maybe there _doprnt
> works fine.
The DJGPP FAQ list mentions a program which can diddle with the 80387
control word to change this behavior:
11.7 Q: I have a program which works with FP emulation, but dies with
``Numeric Exception'' when run on a machine with a
co-processor. It also runs OK when compiled with Microsoft C.
Can't you people make your floating-point code right?
A: This might be still a problem with your program. Under DJGPP,
the 80x87 control word is set up so that it generates an
exception when your program feeds it with a NaN (Not a Number),
while the emulator doesn't have this behavior. You should check
that your program doesn't generate NaNs, or set 80x87 control
word to a different value. There is a program called ctrl87.c
which you can find by anonymous ftp to omnigate.clarkson.edu,
directory pub/msdos/djgpp/pub, which enables this kind of
diddling the 80x87 control word; check it out.
(The latest version of the FAQ is available as faq102.zip from the same
place you get DJGPP.)
- Raw text -