## Applescript:

round 75.5 --> 76 (nearest even integer)

round 74.5 --> 74 (nearest even integer)

round 74.5 rounding as taught in school --> 75 (nearest integer away from zero)

**round** isn't very efficient, though, and the expression **'rounding as taught in school'** may not be something you want to see in one of your own scripts. So if you know the relevant math, using that would be more efficient and possibly more satisfactory.

If you need julifos's handler to work for negatives too, still rounding exact half stages away from zero, this could be a solution:

## Applescript:

roundThis(-75.5436, 1) --> -75.5

on roundThis(n, numDecimals)

set x to 10 ^ numDecimals

tell n * x to return (it div 0.5 - it div 1) / x

end roundThis

Or to round half stages to the nearest even:

]]>## Applescript:

roundThis(-75.545, 2) --> -75.54

on roundThis(n, numDecimals)

set x to 10 ^ numDecimals

tell n * x

if ((it mod 2) ^ 2 > 0.25) then return (it div 0.5 - it div 1) / x

return it div 1 / x

end tell

end roundThis

## Applescript:

round (75.6) --> 76

But how would you round, say 76.5436 to 76.54? Since the round command always produces an integer, you first **multiply** the real number by 100, **round it**, then divide by 100. For example:

## Applescript:

(round (75.5436 * 100)) / 100 --> 75.54

Similarly, to get three decimal places you would use 1000:

## Applescript:

(round (75.5436 * 1000)) / 1000 --> 75.544

You can also use this common routine:

]]>## Applescript:

roundThis(75.5436, 1) --> 75.5

on roundThis(n, numDecimals)

set x to 10 ^ numDecimals

(((n * x) + 0.5) div 1) / x

end roundThis