* John Douglas Porter <[EMAIL PROTECTED]> [2004-04-20 08:39]: > It seems to me that the precision desired should depend on > context, and nothing else. And that being the case... > > printf $fractional_cents ? '%7.3f' : '%7.sf', $amt; > > irrespective of the value of $amt. Why is this not right?
What you have written is neutral with regards to the issue I was referring to. If you do this by looking at $amt, then your method must be mathematical, because chopping characters in the string representation of the unrounded $amt might occasionally lead to results different from what the mathematical method would have produced with rounding involved. If you already do have a string representation consistent with a rounded $amt, f.ex using sprintf, then it's safe to mangle this as a string. So the key here would be what expression decides the value of your $fractional_cents boolean. And I as I posted a bit before, it *can* (of course) be done using just math. -- Regards, Aristotle "If you can't laugh at yourself, you don't take life seriously enough."