Algorithm that converts numeric amount into English words

后端 未结 9 1039
眼角桃花
眼角桃花 2020-12-13 21:44

What is the most efficient way to convert numeric amount into English words

e.g. 12 to twelve 127 to one hundred twenty-seven

9条回答
  •  生来不讨喜
    2020-12-13 22:04

    .) make a library of all numbers & positions (e.g. 1 has other notation than 10, another than 100 etc) .) make a list of exceptions (e.g. for 12) and be aware, that in your algorythm, the same exception are for 112, 1012 etc.

    if you want even more speed, make a cached set of numbers that you need.

提交回复
热议问题