in reply to May I be bitten by floating point arithmetic in the following restricted case?
As you know, a tiny error log($size) / log(2) could lead to a big error in the result. Perl Differences in the underlying C libraries and hardware can result in those tiny differences on other systems even if they don't exist on your own.
I suppose the error coming from floating point arithmetic can bite me only in the case when $size is a power of 2
You also need to check one less than powers of two for errors rounding up.
249 = 562949953421312
$ perl -E'say int( log(562949953421309) / log(2) )' 48 $ perl -E'say int( log(562949953421310) / log(2) )' 49 XXX $ perl -E'say int( log(562949953421311) / log(2) )' 49 XXX $ perl -E'say int( log(562949953421312) / log(2) )' 49 $ perl -E'say int( log(562949953421313) / log(2) )' 49
(Problem found by accident)
In Section
Seekers of Perl Wisdom