Skip Menu |

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

Report information
The Basics
Id: 27521
Status: resolved
Priority: 0/
Queue: Math-GMP

People
Owner: Nobody in particular
Requestors: sisyphus [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.04
Fixed in: (no value)



Subject: Math::GMP->new($NV) assigns a value of 0
C:\_32>perl -MMath::GMP -e "print $Math::GMP::VERSION" 2.04 C:\_32>perl -MMath::GMP -we "print Math::GMP->new(1.5)" 0 C:\_32>perl -MMath::GMP -we "print Math::GMP->new(2 ** 50 - 1)" 0 C:\_32> Given that the GMP library will assign the truncated integer value of a double (using the 'mpz_set_d' function), shouldn't Math::GMP do the same ? ... or at least *warn* that a value of zero is being assigned ? ... or maybe even die with the complaint that one can't assign an NV to a Math::GMP object ? Actually, such a complaint would be a little simplistic because the NV (eg) 126.0 *does* get appropriately assigned: C:\_32>perl -MDevel::Peek -e "Dump(126.0)" SV = NV(0x4366a4) at 0x3e3bec REFCNT = 1 FLAGS = (PADBUSY,PADTMP,NOK,READONLY,pNOK) NV = 126 C:\_32>perl -MMath::GMP -we "print Math::GMP->new(126.0)" 126 Anyway, it seems inappropriate to me that a value of zero is silently assigned in the first two examples provided above. Cheers, Rob
On Sun Jun 10 09:18:17 2007, SISYPHUS wrote: Show quoted text
> C:\_32>perl -MMath::GMP -e "print $Math::GMP::VERSION" > 2.04 > C:\_32>perl -MMath::GMP -we "print Math::GMP->new(1.5)" > 0 > C:\_32>perl -MMath::GMP -we "print Math::GMP->new(2 ** 50 - 1)" > 0 > C:\_32> > > Given that the GMP library will assign the truncated integer value of a > double (using the 'mpz_set_d' function), shouldn't Math::GMP do the > same ? ... or at least *warn* that a value of zero is being > assigned ? ... or maybe even die with the complaint that one can't > assign an NV to a Math::GMP object ? > > Actually, such a complaint would be a little simplistic because the NV > (eg) 126.0 *does* get appropriately assigned: > > C:\_32>perl -MDevel::Peek -e "Dump(126.0)" > SV = NV(0x4366a4) at 0x3e3bec > REFCNT = 1 > FLAGS = (PADBUSY,PADTMP,NOK,READONLY,pNOK) > NV = 126 > > C:\_32>perl -MMath::GMP -we "print Math::GMP->new(126.0)" > 126 > > Anyway, it seems inappropriate to me that a value of zero is silently > assigned in the first two examples provided above.
Hi, thanks for the report - we now throw an exception in this case. Will be on CPAN soon. Regards, -- Shlomi Fish. Show quoted text
> > Cheers, > Rob