cnfsstat rounding trouble
hakehoe at avalon.net
Sun May 23 17:49:40 UTC 2004
-----BEGIN PGP SIGNED MESSAGE-----
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.
>> 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";
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
-----END PGP SIGNATURE-----
More information about the inn-workers