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:
parent
253e932816
commit
d5f16a867c
1 changed files with 22 additions and 17 deletions
|
|
@ -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: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue