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