-----BEGIN PGP SIGNED MESSAGE----- Moin all, I am now between a rock and a hard place: POSIX::floor () converts the 81 as result to 80, as does int(). sprinf("%.0f"), OTOH, converts this fine to 81, but it fails for things like 9.91234 - this should be truncated to 9, but sprintf rounds it to 10. Here is a case where the new sprintf("%.0f") fails, but the former int() works: # perl -Mbigint -le 'print 9999->broot()' 99 # perl -Ilib -Mbigint -le 'print 9999->broot()' 100 And here is one where the old one fails, but the new one works: # perl -Mbigint -le 'print +(81 ** 3)->broot(3)' 80 # perl -Ilib -Mbigint -le 'print +(81 ** 3)->broot(3)' 81 :-( Hm, Paul Johnson <paul@pjcj.net> wrote: >Because (81 ** 3) ** (1/3) != 81 > >$ perl -le 'print ((81 ** 3) ** (1/3) != 81)' >1 > >$ perl -MPOSIX -le '$a = (81 ** 3) ** (1/3); print join(" ", $a, int ($a), >POSIX::floor($a), sprintf("%f",$a), sprintf("%.20f",$a), sprintf >("%.0f",$a))' >81 80 80 81.000000 80.99999999999998578915 81 Argl. So, if I first round the result to 8 digits after the ".", I get rid of the small variances, and can the truncate the result properly? Or should I just add 0.5? Decisions.... $x->[0] = int ( sprintf ("%.8f", $x->[0] ** (1 / $n->[0]) ) ); This seems to work for both cases on my system..... Best wishes, Tels - -- Signed on Tue Oct 7 20:25:12 2003 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email. "My glasses, my glasses. I cannot see without my glasses." - "My glasses, my glasses. I cannot be seen without my glasses." -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. iQEVAwUBP4MLkncLPEOTuEwVAQEzdAf+LvKuV3zbxYOSvJYBrb0PBs29Jo70UTdl hKVlIK8aJnslvkWXiusnnApFpxMgby17HgE96KiRLq7Iz9RK+9XOVXq0XQhrmhmL UVE634ZGMlhBiwidyzFz82j5ngO/2wuzxHHBDI2W6w811ItEs7e0tpSC1cx4cIH/ HI1gNVhzZ77QtUEZtJsI1Vsw+q5dEHnVV2R2MPagxl1reO1vcLVS2ehW2tHLAZW3 +bN3YGU9x4j1xNZvejcVgP4PpECl7b1ywb5dJfO0kZ1U3HKcdzX5TAV2ZQbgybiR DIwcompM7k6AZqYO6PD4kP1iFCH4l3UOUpTtjAh1SIVsxJWYKfeoNQ== =MjYf -----END PGP SIGNATURE-----