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();
# the pack dance is to get plain old NVs out of the
# Math::BigInt objects.
my $inf = unpack 'd', pack 'd', Math::BigInt->binf();
my $nan = unpack 'd', pack 'd', Math::BigInt->bnan();
batch('float',
-(2 - 2 ** -23) * 2 ** 127, -(2 - 2 ** -23) * 2 ** 127,
-1, -2 ** -149, 0, 2 ** -149, 1, -1, -2 ** -149, 0, 2 ** -149, 1,
(2 - 2 ** -23) * 2 ** 127, (2 - 2 ** -23) * 2 ** 127,
'nan'); $nan);
{ local $TODO = "shouldn't some Inf <=> float work?"; { local $TODO = "float typemaps don't pass infinity";
# I'm going to guess that it could work reasonably as # it seems as though SWIG is unwilling to pass infinity around
# NV Inf => float Inf # because that value always fails bounds checking. I think that
# float Inf => NV NaN # is a bug.
# but this needs some thought. batch('float', $inf);
batch('float', 'inf'); }
} batch('double',
batch('double',
-(2 - 2 ** -53) ** 1023, -(2 - 2 ** -53) ** 1023,
-1, -2 ** -1074, 0, 2 ** 1074, -1, -2 ** -1074, 0, 2 ** 1074,
(2 - 2 ** -53) ** 1023, (2 - 2 ** -53) ** 1023,
'nan', 'inf'); $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: {