Skip to Content
0
Former Member
Dec 06, 2006 at 06:34 PM

Function to format numbers

112 Views

Hello,

I am trying to write a function that does the following 2 things:

If a number is an integer, first add .00 after the integer, then add zeros in front such that altoghther it makes 9 characters (e.g.: 12 -> 000012.00)

If a number is not an integer, then ensure it is 2 decimals by truncating whatever that is after the 2 decimals and add 0 in fron as well (e.g. 12.12345 -> 000012.12)

There would be no number larger than 6 digits (i.e., 9 characters altogether)

Does anyone know whether there is any existing function or method that would do the job or at least part of it?

Thanks!

Regards,

Anyi