cnfsstat rounding trouble

Heath Kehoe hakehoe at
Sun May 23 17:49:40 UTC 2004

Hash: SHA1

On May 23, 2004, at 12:23, Christoph Biedl wrote:

> Heath Kehoe wrote...
>> The variables $free, $len, and $val are BigInts; and perl doesn't
>> convert their values to floating point automatically for division.
> Yes.
>> I believe that when you eval() a BigInt, perl converts it to a
>> regular number value (either an integer or a float) with some loss
>> of accuracy.  But it's not explicitly documented in the BigInt docs,
>> so I'm not sure we should rely on it.
> accuracy loss shouldn't be a problem for integer numbers, isn't it?
> A shorter way was to do
> | $free = "$free";
> 	Christoph

True, unless the BigInt value is larger than what will fit in a scalar
integer (greater than 2^31, unless perl was compiled to use 64-bit
ints), where perl will convert the value to a scalar float; and in that
case you'll lose some accuracy.  But for the purposes of cnfsstat,
a little loss of accuracy is no big deal.

I like your solution best ($free = "$free")

- - heath
Version: GnuPG v1.2.4 (Darwin)


More information about the inn-workers mailing list