19 January 2007 @ 12:40Rounding to the nearest even number
I was looking for a way to have an AppleScript round a number to the nearest even, whole number. I did some googling and found some examples of rounding with AppleScript, but I had to modify them to do exactly what I wanted. Here is what I came up with:
property this_number : ""
display dialog "Enter a number" default answer this_number
set the this_number to text returned of result
set rounded to (round (this_number) rounding up)
if rounded mod 2 is not 0 then
set evenNum to (rounded - 1)
else
set evenNum to rounded
end if
by Jon | Add a comment | Tags: applescript, round to nearest even number, rounding
Posted in applescript | Link to this