On Tue, Oct 07, 2003 at 08:20:00PM +0200, Tels wrote: > On Tuesday 07 October 2003 20:12, Tels wrote: > > This is very wierd: > > # perl -MPOSIX -le '$a = (81 ** 3) ** (1/3); print join(" ", $a, int ($a), > POSIX::floor($a), sprintf("%f",$a), sprintf ("%.0f",$a))' > 81 80 80 81.000000 81 > > Why is $a sometimes 81, and sometimes 80? Why does int(81) produce 80? 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 -- Paul Johnson - paul@pjcj.net http://www.pjcj.net