in reply to A simple rounding question, but can't get it!

In cb, you indicated that the general problem is to do a Banker's Round, where /\d5/ is rounded to the even digit. I think you want to work with the string representation of the number for this, so that machine numbers don't interfere with the rules.

# handle 5 in the thousandth's place with nothing or zeros following $pete =~ s/( # substitute, start capture $1 \d* # none or more digits \. # a decimal point \d # tenths digit (\d) # capture hundredths digit as $2 ) # end capture $1 50*$ # digit 5 followed by none or more 0's to the end /1&$2 ? $1+.01 : $1/xe; # then do as you had $rooker = sprintf "%.2f", $pete;
By handling the special case as a string before the numeric round, we avoid binary-meets-decimal conflicts.

After Compline,
Zaxo