in reply to Re^20: supporting quads on 32 bit Perl
in thread supporting quads on 32 bit Perl
I just tried 0.23 from CPAN. Math::Int64 doesn't croak when called by Test::More after a test failed anymore. Compiled without errors. I used it in my module and write a small test suite that uses Math::Int64 without any problems. I did fail a test from Math::Int64 though.
edit: given this XS Func
== 100001111101111111000000000000000000000000000000000000000000000
chop off sign bit
00001111101111111000000000000000000000000000000000000000000000
chop off exponent (11 bits)
111111000000000000000000000000000000000000000000000
== 0x7E00000000000
0x7E00000000000 2 216 615 441 596 416 unsigned __int64
IDK. I'm not a math person.
(two->sv_any->xnv_u.xnv_nv) > (2^53) true bool
0xff00000000000000 > (2^53) true bool
I don't have an infinite precision calc on hand, but 0xFF would be 64-8=56. Doubles store integers upto 2^53. There even is a Perl C const just for this, win32/config_H.vc#l4320 in perl.git.
I'll try to update this node soon on what I think about the failed test XS wise if your not faster than me in fixing it.Microsoft (R) Program Maintenance Utility Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved. C:\perl512\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib\lib', 'blib\arch')" t/*.t t/as_int64.t ............ ok t/die_on_overflow.t ..... ok t/Math-Int64-Native.t ... ok t/Math-Int64.t .......... ok t/Math-UInt64-Native.t .. ok t/Math-UInt64.t ......... ok t/MSC.t ................. 1/3 # Failed test 'uint64 to NV conversion 3' # at t/MSC.t line 15. # Looks like you failed 1 test of 3. t/MSC.t ................. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/3 subtests t/pods.t ................ skipped: Only the author needs to check that + POD docs are right Test Summary Report ------------------- t/MSC.t (Wstat: 256 Tests: 3 Failed: 1) Failed test: 3 Non-zero exit status: 1 Files=8, Tests=256, 1 wallclock secs ( 0.24 usr + 0.02 sys = 0.25 C +PU) Result: FAIL Failed 1/8 test programs. 1/256 subtests failed. NMAKE : fatal error U1077: 'C:\perl512\bin\perl.exe' : return code '0x +ff' Stop. C:\Documents and Settings\Owner\Desktop\cpan libs\Math-Int64-0.23> C:\Documents and Settings\Owner\Desktop\cpan libs\Math-Int64-0.23>perl + ./t/MSC.t 1..3 ok 1 - uint64 to NV conversion ok 2 - uint64 to NV conversion 2 not ok 3 - uint64 to NV conversion 3 # Failed test 'uint64 to NV conversion 3' # at ./t/MSC.t line 15. # Looks like you failed 1 test of 3. C:\Documents and Settings\Owner\Desktop\cpan libs\Math-Int64-0.23>
edit: given this XS Func
called asvoid TwoSVs( one, two ) SV * one SV * two PPCODE: 0;
which showedmy $u = string_to_uint64('0xff00_0000_0000_0000'); Dump($u); my $nv = uint64_to_number($u); Dump($nv); Local::XS::TwoSVs($u, $nv);
$u's &($u->sv_u.svu_rv->sv_any->xnv_u) in raw memory isSV = IV(0xb04240) at 0xb04244 REFCNT = 1 FLAGS = (PADMY,ROK) RV = 0x397e8c SV = PVMG(0x8eaf6c) at 0x397e8c REFCNT = 1 FLAGS = (OBJECT,NOK,OVERLOAD,pNOK) IV = 0 NV = -5.48612406879369e+303 PV = 0 STASH = 0x8616cc "Math::UInt64" SV = NV(0x86ab0c) at 0x82bd0c REFCNT = 1 FLAGS = (PADMY,NOK,pNOK) NV = 1.83746864796716e+019
$nv's &($nv->sv_any->xnv_u) in raw memory is0x008EAF6C 00 00 00 00 00 00 00 ff
ok lets try this0x0086AB0C 00 00 00 00 00 e0 ef 43
result ismy $u = string_to_uint64('0xff00_0000_0000_0000'); my $nv = uint64_to_number($u); print "nv $nv u $u \n\n";
IDK how many floating point digits are supposed to be shown. VS debugger says the NV slot in the SVNV is "1.8374686479671624e+019".nv 1.83746864796716e+019 u 18374686479671623680
== 0x43efe00000000000(__int64 *)&(two->sv_any->xnv_u)
== 100001111101111111000000000000000000000000000000000000000000000
chop off sign bit
00001111101111111000000000000000000000000000000000000000000000
chop off exponent (11 bits)
111111000000000000000000000000000000000000000000000
== 0x7E00000000000
0x7E00000000000 2 216 615 441 596 416 unsigned __int64
IDK. I'm not a math person.
(two->sv_any->xnv_u.xnv_nv) > (2^53) true bool
0xff00_0000_0000_0000 is more than 2^53, it can't be held in a NV cleanly.my $u = string_to_uint64('0xff00_0000_0000_0000'); my $nv = uint64_to_number($u);
0xff00000000000000 > (2^53) true bool
I don't have an infinite precision calc on hand, but 0xFF would be 64-8=56. Doubles store integers upto 2^53. There even is a Perl C const just for this, win32/config_H.vc#l4320 in perl.git.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^22: supporting quads on 32 bit Perl
by salva (Canon) on Jun 04, 2012 at 21:33 UTC | |
by bulk88 (Priest) on Jun 04, 2012 at 22:50 UTC | |
by salva (Canon) on Jun 05, 2012 at 09:40 UTC | |
by bulk88 (Priest) on Jun 05, 2012 at 16:33 UTC | |
by salva (Canon) on Jun 06, 2012 at 14:21 UTC | |
|
In Section
Seekers of Perl Wisdom