Number to text

This topic is 7817 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi everybody,

Can some want know a technics script to convert a number to a text.

Ex: 120 - Hundred and twenty

I really appreciate that.

Share on other sites

This is a big job because it all has to be hard-coded in. Because it's hard-coded it will have a limit to the maximum number it will process.

I think (not sure) that there is a calculation that does this at http://www.databasepros.com in the tips section or something.

Share on other sites

I have done this for numbers up to 999,999,999. I found the best tradeoff between complexity and effort is to use a combination of calculations and a related file that holds the text version of numbers from 1 to 99.

Break the number into groups of 3 digits. The first group is millions; the second group is thousands, and the last is units. Each of these is then broken into sub-groups consisting of the first digit, and the last two digits. This gives a total of 6 sub-groups. Create six relationships between the main file and the text lookup file based on each of these sub-group values.

Each group is processed the same way. If a group is > 99 then lookup the text equivalent for the first digit and append "hundred" then lookup and concatenate the text for the last two digits. If the group value is zero, the resulting text should be an empty string.

For the first group, if the string is not empty, append "million "

For the second group, if the string is not empty, append "thousand "

Finally, concatenate all strings together.

Share on other sites

• 2 weeks later...

Thanks a lot I found a lot of useful tip .

quote:

Originally posted by Vaughan:

This is a big job because it all has to be hard-coded in. Because it's hard-coded it will have a limit to the maximum number it will process.

I think (not sure) that there is a calculation that does this at
in the tips section or something.

Share on other sites

This topic is 7817 days old. Please don't post here. Open a new topic instead.

Create an account

Register a new account