Hopefully this provides more portable values for Infinity and NaN in Perl.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10616 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Robert Stone 2008-06-30 23:41:27 +00:00
commit d5f16a867c

View file

@ -37,24 +37,29 @@ batch('ulong', 0, 1, 12, 0xffffffff);
batch('uchar', 0, 1, 12, 0xff); batch('uchar', 0, 1, 12, 0xff);
batch('schar', -0x80, 0, 1, 12, 0x7f); batch('schar', -0x80, 0, 1, 12, 0x7f);
# IEEE 754 machine, please! {
batch('float', use Math::BigInt qw();
-(2 - 2 ** -23) * 2 ** 127, # the pack dance is to get plain old NVs out of the
-1, -2 ** -149, 0, 2 ** -149, 1, # Math::BigInt objects.
(2 - 2 ** -23) * 2 ** 127, my $inf = unpack 'd', pack 'd', Math::BigInt->binf();
'nan'); my $nan = unpack 'd', pack 'd', Math::BigInt->bnan();
{ local $TODO = "shouldn't some Inf <=> float work?"; batch('float',
# I'm going to guess that it could work reasonably as -(2 - 2 ** -23) * 2 ** 127,
# NV Inf => float Inf -1, -2 ** -149, 0, 2 ** -149, 1,
# float Inf => NV NaN (2 - 2 ** -23) * 2 ** 127,
# but this needs some thought. $nan);
batch('float', 'inf'); { local $TODO = "float typemaps don't pass infinity";
# it seems as though SWIG is unwilling to pass infinity around
# because that value always fails bounds checking. I think that
# is a bug.
batch('float', $inf);
}
batch('double',
-(2 - 2 ** -53) ** 1023,
-1, -2 ** -1074, 0, 2 ** 1074,
(2 - 2 ** -53) ** 1023,
$nan, $inf);
} }
batch('double',
-(2 - 2 ** -53) ** 1023,
-1, -2 ** -1074, 0, 2 ** 1074,
(2 - 2 ** -53) ** 1023,
'nan', 'inf');
batch('longlong', -1, 0, 1, 12); batch('longlong', -1, 0, 1, 12);
batch('ulonglong', 0, 1, 12); batch('ulonglong', 0, 1, 12);
SKIP: { SKIP: {