* Bernie Cosell <[EMAIL PROTECTED]> [2004-04-22 00:02]:
> On 21 Apr 2004 at 22:55, A. Pagaltzis wrote:
> > 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.
> 
> Correct, but doesn't "%.Xf" round?  And so running it through
> the (s)printf before you mess with it gets you the desired
> rounding, doesn't it?

Yes, that's what I said further down in my mail.

The point is that using something like $amt =~ /\.\d\d\d/ will
probably lead to inconsistencies because $amt is unrounded, while
printf then produces a rounded form that depends on at least one
more digit, probably also on whether the non-fractional part is
odd or even, and a number of other factors.

So if your conditional refers to $amt, it should use math, like
($amt * 1000) % 10.

You *can* use string mangling, however, if you mangle the
*result*.

> When you're pricing things, prices are in dollars and cents....
> except for [...]

I know what he wanted and why, and wasn't even saying anything
about that.

-- 
Regards,
Aristotle
 
"If you can't laugh at yourself, you don't take life seriously enough."

Reply via email to