Skip Menu |

This queue is for tickets about the Math-BigInt CPAN distribution.

Report information
The Basics
Id: 14254
Status: resolved
Worked: 10 min
Priority: 0/
Queue: Math-BigInt

People
Owner: TELS [...] cpan.org
Requestors: richard_a_brunner [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.77
Fixed in: (no value)



Subject: possible as_hex() bug?
## as_hex() bug? $x is divided by 16 (shifted by a hex digit) and copied ## to $y. $y->floor()->$as_hex() should show remaining hex digits but ## doesn't. $y appears to be correct BigFloat value, so error seems ## to be in as_hex() ... ## ## Script returns: ## x = 18441921395236213128, 0xffeeddccaabb1188 ## y = 1152620087202263320, as_hex=0xffeeddccaaba420, ## should be=0xffeeddccaabb118 use bignum; $x = 0xffeeddccaabb1188; printf( "x = %s, %s\n",$x, $x->as_hex() ); $x = $x/16; $y = $x->copy()->bfloor(); printf( "y = %s ,as_hex=%s, should be=%s\n",$y,$y->as_hex(), my_hex($y) ); exit; sub my_hex { my($num) = @_; my $blog = $num->copy()->blog(16)->bfloor(); my $ret = "0x"; for (my $j = $blog; $j >= 0; $j--){ my $mypow = 16**$j; for (my $i = 15; $i >=0 ; $i--){ $mytry = $mypow*$i; next if ( $mytry > $num ); $num = $num - $mytry; $ret .= sprintf("%x",$i); last; } } return $ret; } __END__ C:> perl -v This is perl, v5.8.4 built for MSWin32-x86-multi-thread (with 3 registered patches, see perl -V for more detail) Copyright 1987-2004, Larry Wall Binary build 810 provided by ActiveState Corp. http://www.ActiveState.com ActiveState is a division of Sophos. Built Jun 1 2004 11:52:21
From: Tels <nospam-abuse [...] bloodgate.com>
To: bug-Math-BigInt [...] rt.cpan.org
Subject: Re: [cpan #14254] possible as_hex() bug?
Date: Mon, 22 Aug 2005 18:55:55 +0200
RT-Send-Cc:
-----BEGIN PGP SIGNED MESSAGE----- Moin, On Monday 22 August 2005 07:54, Guest via RT wrote: Show quoted text
> This message about Math-BigInt was sent to you by guest <> via > rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=14254 > > > ## as_hex() bug? $x is divided by 16 (shifted by a hex digit) and > copied ## to $y. $y->floor()->$as_hex() should show remaining hex > digits but ## doesn't. $y appears to be correct BigFloat value, so > error seems ## to be in as_hex() ...
Dumping $y with Data::Dumper reveals: $y = $VAR1 = bless( { '_m' => [ 2263320, 2008720, 11526 ], '_es' => '+', '_e' => [ 0 ], 'sign' => '+' }, 'Math::BigFloat' ); This is internally wrong, it should have been: new(1152620087202263320) = $VAR1 = bless( { '_es' => '+', '_m' => [ 226332, 6200872, 1152 ], '_e' => [ 1 ], 'sign' => '+' }, 'Math::BigFloat' ); e.g. it was not properly reduced to have the minimum E. I'll look into this. Best wishes, Tels - -- Signed on Mon Aug 22 18:45:15 2005 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email. "The rovers Spirit and Opportunity were proposed, authorized, announced, designed, launched and successfully landed upon Mars within the timeframe of Duke Nukem Forever's development." - Unknown -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iQEVAwUBQwoDoncLPEOTuEwVAQFi4Qf8D3Qp2QTGbrs97jw8f1vqnEkWYep/IZ1n w3pUVbGunmjmWNiczpWkv827lBZ3sph6L0ztpRuwycB7JUc/f5X5PUSjxJGT1lyY sWYJmRFmnMTtDuSQOjWLEPrnm0+os6QPkQzliAoMYLzqC05qCx3ZHi/py0JuSVEM dUpM/yhvnxbGiOkLgIpy0cK/r8JrZ9c9ZNzwmdFhhagR30abGZPIkcX4zhFNSBVM Cmt9m+g+AaBaArqXluoKMav6U5UlHxQ2QZhOHnDackJ/O0FfBbU7NjrRtp3wvBQN TsR/kPZ1DfkWP/iIsv8mbHM17oN4ED33sQ3KrrlH+z/SgxNk5bqniQ== =pQXz -----END PGP SIGNATURE-----
From: richard_a_brunner [...] yahoo.com
Perl -V info: Summary of my perl5 (revision 5 version 8 subversion 4) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX', optimize='-MD -Zi -DNDEBUG -O1', cppflags='-DWIN32' ccversion='', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -libpath:"Z:\bin\apps\win\perl\lib\CORE" -machine:x86' libpth=C:\PROGRA~1\MICROS~3\VC98\lib libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib gnulibc_version='undef' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -libpath:"Z:\bin\apps\win\perl\lib\CORE" -machine:x86' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS Locally applied patches: ActivePerl Build 810 22751 Update to Test.pm 1.25 21540 Fix backward-compatibility issues in if.pm Built under MSWin32 Compiled at Jun 1 2004 11:52:21 @INC: Z:/bin/apps/win/perl/lib Z:/bin/apps/win/perl/site/lib .
I can no longer reproduce this problem on my current development machine. Does it still occur for you?
I am marking this as resolved, if this issue still appears for you, please re-open this bug by replying to this message. Thank you for your report!