Vim is wrong.
It's been years since I last dealt with this. It's a kludge intended to work
around pre IEEE 754 CPUs and RISC implementations that do not handle NaN
properly. I don't think that's an issue today. I had to deal with it when I
was porting software from VAX to 6 versions of Unix on 5 species of CPU circa
1992 (MIPS, SPARC, Power, Clipper and HP "Snake"). Code intended to run on
VAXen and older processors had lots of this sort of junk. It was also an issue
with early RISC CPUs.
A cursory consideration of your test will show that you can't create a NaN in
the fashion you attempted.
The preprocessor expands the code into "a-a" which equals zero.
The proper way to test for NaN is:
if (a != a){
// NaN
}
We should not have issues with IEEE 754 conformance on x86. If someone doesn't
reply with a fix, email me and I'll take a look at vim and fix it. Even though
I despise vim ;-)
Reg
--------------------------------------------
On Tue, 11/29/16, Alexander Pyhalov <[email protected]> wrote:
Subject: [discuss] DBL_MAX + DBL_MAX
To: "[email protected]" <[email protected]>
Date: Tuesday, November 29, 2016, 7:48 AM
Hello.
I've found this in vim code (compiled with -m32):
# if !defined(INFINITY)
# if defined(DBL_MAX)
# ifdef VMS
# define INFINITY DBL_MAX
# else
# define INFINITY (DBL_MAX+DBL_MAX)
# endif
# else
# define INFINITY (1.0 / 0.0)
# endif
# endif
# if !defined(NAN)
# define NAN (INFINITY-INFINITY)
# endif
This essentially defines INFINITY to DBL_MAX+DBL_MAX and
NAN as INFINITY-INFINITY.
We have #define DBL_MAX
1.7976931348623157081452E+308
And if I try to do
printf ("%f\n",NAN);
I receive "0.000000" with '-m32' and -INF wiht
'-m64'.
Who is wrong here?
vim assuming that DBL_MAX + DBL_MAX is infinity? Compiler?
Our headers?
--
Best regards,
Alexander Pyhalov,
system administrator of Southern Federal University IT
department
-------------------------------------------
illumos-discuss
Archives: https://www.listbox.com/member/archive/182180/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182180/21175430-2e6923be
Modify Your Subscription:
https://www.listbox.com/member/?member_id=21175430&id_secret=21175430-6a77cda4
Powered by Listbox: http://www.listbox.com