<?xml version="1.0" encoding="windows-1252"?>
<node id="984833" title="Re: Using (s)printf()" created="2012-08-01 12:59:27" updated="2012-08-01 12:59:27">
<type id="11">
note</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
&lt;p&gt;Your statement and example under "Rounding Numbers with sprintf()" is incorrect and misleading.  Using "%d" does NOT round a float as necessary, it merely truncates everything after the decimal.  Thus,
&lt;c&gt;printf("%d", 3.99);&lt;/c&gt;  # will print 3, not 4.&lt;/p&gt;
&lt;c&gt;
# To properly 'round a float as necessary':
printf("%.0f", 3.49); # This will print 3
printf("%.0f", 3.51); # This will print 4
&lt;/c&gt;</field>
<field name="root_node">
20519</field>
<field name="parent_node">
20519</field>
<field name="reputation">
1</field>
</data>
</node>
