<?xml version="1.0" encoding="windows-1252"?>
<node id="161255" title="Answer: How do I round a number?" created="2002-04-23 07:44:43" updated="2005-08-11 07:39:49">
<type id="1888">
categorized answer</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
Here shown all round-like functions which exists in perl:&lt;BR&gt;

&lt;CODE&gt;
#!/usr/bin/perl
use POSIX;
@a=(3.3, 3.5, 3.7, -3.3, -3.5, -3.7, 3.45);
print "number\tint\tprintf\tfloor\tceil\n";
printf "%.2f\t%.1f\t%.1f\t%.2f\t%.2f\n",
	$_,
	int,
	$_,
	floor($_),
	ceil($_)
foreach (@a);
&lt;/CODE&gt;

This code produce this output:&lt;BR&gt;

&lt;PRE&gt;
number	int	printf	floor	ceil
3.30	3.0	3.3	3.00	4.00
3.50	3.0	3.5	3.00	4.00
3.70	3.0	3.7	3.00	4.00
-3.30	-3.0	-3.3	-4.00	-3.00
-3.50	-3.0	-3.5	-4.00	-3.00
-3.70	-3.0	-3.7	-4.00	-3.00
3.45	3.0	3.5	3.00	4.00
&lt;/PRE&gt;
</field>
<field name="parent_node">
24335</field>
</data>
</node>
