number to alpha
-
hi all, i'm trying converting numbers to alpha. for example if i write 30 it'll give me "thirty" or 31 - "thirtyone"... how can i do that?? thanx...
Wow, that would not be too hard but would require more time to explain than I think most of us would be willing to put in, but if it's okay, let me get you started and I think you can figure the rest out on your own. seperate your problem into periods. A period is the three number grouping deliniating hundreds, thousands, millions .... ie 42,233,123 so this should convert to the string "fouty two million, two hundred thirty three thousand, one hundred twenty three" right? so now you have three strings : "42" , "233", "123" now take each of those strings and make a post-period-word for them to tack on later, so you'd have: "Million", "Thousand" Dont worry about the last string, that one will just be worded on its own. now convert the number in each of the strings and convert them into words. You can figure this out on your own and its not too hard but think carefully about it, there are some special cases here! This is kind of a recursive algorithm but there are a few special cases you'll need to code for like not wording the last group. For instance you would not want to save "One Hundred Twenty Three Hundred". Have fun.
-
hi all, i'm trying converting numbers to alpha. for example if i write 30 it'll give me "thirty" or 31 - "thirtyone"... how can i do that?? thanx...
Take a look at this article[^] :) David Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy