You should have a look at DEC and DIG modifier and keep your maths as is.