There are actually standards regarding how rounding should be done, e.g. http://en.wikipedia.org/wiki/IEEE_floating_point#Rounding_rules (which is probably not universally followed) and ISO 717-1:1996. On the other hand, since floating point numbers are not real numbers (they're a subset of rational numbers), there will be times when sprintf will round the value it's given correctly, but the value that it gets is not correct, depending on how well the floating point library is written (some are much better than others) and the details of the computations being done
I've had to deal with hand-rolled rounding solutions (so that rounded numbers would add up to an integral value). You may have to roll your own rounding subroutine if you've got specific requirements.
Information about American English usage here and here. Floating point issues? Please read this before posting. — emc
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||