On Wed, Oct 08, 2003 at 10:09:28PM -0400, Ed Allen Smith <easmith@beatrice.rutgers.edu> wrote: > In message <20031009011103.GA3456@efn.org> (on 8 October 2003 18:11:03 > -0700), sthoenna@efn.org (Yitzchak Scott-Thoennes) wrote: > > >How about this: > > > >--- lib/Math/BigInt/Calc.pm.orig 2003-10-08 15:31:26.583782400 -0700 > >+++ lib/Math/BigInt/Calc.pm 2003-10-08 15:43:00.251227200 -0700 > >@@ -1423,7 +1423,10 @@ > > else > > { > > # fit's into one Perl scalar, so result can be computed directly > >- $x->[0] = int( $x->[0] ** (1 / $n->[0]) ); > >+ my $result = int( $x->[0] ** (1 / $n->[0]) + .5); > >+ # see if we rounded up inappropriately > >+ --$result if $result ** $n->[0] > $x->[0]; > >+ $x->[0] = $result; > > } > > return $x; > > } > >End of Patch. > > I like it overall, except that I'm wondering given rounding wierdnesses > whether it might be best to check specifically what the result is without > the +.5. Not sure exactly what you mean. The rounded value will either be the truncated result or one more than it. That way, if something goes wrong with the $result**$n->[0] check > (say it's 0.000000001 greater than $x->[0]), it'll just revert to the > behavior without the +0.5. You shouldn't get that kind of inaccuracy with an integer ** integer calculation. Nevertheless, I guess you could say: --$result if int($result ** $n->[0] + .5) > $x->[0];