<div class="gmail_extra">Perhaps I'm mistaken about something, but it should "round half to even". Still, if you look up round in perlfaq4 it gives a little more information about what you are seeing (perldoc -q round).</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">You may have to take its advice and implement your own rounding algorithm, but I'm sure there must be something on CPAN for this.</div><div class="gmail_extra">
<br></div><div class="gmail_extra">Joel<br><br><div class="gmail_quote">On Fri, Apr 27, 2012 at 8:54 PM, Michael Potter <span dir="ltr"><<a href="mailto:michael@potter.name" target="_blank">michael@potter.name</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Monks,<br>
<br>
I am looking for a graceful way to round numbers.<br>
<br>
The following program<br>
#!/bin/perl<br>
<br>
sub myround<br>
{<br>
   my $src = shift;<br>
   printf("%.2f\n", $src);<br>
}<br>
<br>
myround("1.335");<br>
myround("0.335");<br>
<br>
outputs this:<br>
$ perl ./<a href="http://round.pl" target="_blank">round.pl</a><br>
1.33<br>
0.34<br>
<br>
I know why.  It has to do with the well known side effects of using<br>
floating point.<br>
<br>
What I don't know is a graceful way to round.<br>
<br>
I would like to use something that already comes with perl and void<br>
adding any modules.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
potter<br>
_______________________________________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br>
</font></span></blockquote></div><br></div>