gubbfett
gubbfett

Reputation: 2177

Convert integer to number in text

This may be an akward question but is there any built in function in .net for translating an integer to a describing text?

That is, if i have the value 1 i want to print it as the string one. If the value is 22, i want the string twenty-two and so on, or do i have to build my own function/algorithm for this?

Yes, the most common is to use 0 to 9 as explaining text and ten and above displayed in numbers, but I still wonder, and I guess I can't find anything about it since it's not possible? VB or C# does not matter.

Upvotes: 0

Views: 119

Answers (2)

Margus
Margus

Reputation: 20038

You can wolfram it :

number name 123456

If you use mathematica aka wolfram language, then you have interface for it and you can use: https://mathematica.stackexchange.com/questions/1065/how-to-express-an-integer-number-in-english-words

To call Mathematica from c# you can use JLink.

It is not meant as most cost effective solution, but it is guaranteed to be right. For example 71! is

850 duotrigintillion 478 untrigintillion 588 trigintillion 567 novemvigintillion 862 octovigintillion 317 septenvigintillion 521 sexvigintillion 167 quinvigintillion 644 quattuorvigintillion 239 trevigintillion 926 duovigintillion 10 unvigintillion 288 vigintillion 584 novemdecillion 608 octodecillion 120 septendecillion 796 sexdecillion 235 quindecillion 886 quattuordecillion 430 tredecillion 763 duodecillion 388 undecillion 588 decillion 680 nonillion 378 octillion 79 septillion 17 sextillion 697 quintillion 280 quadrillion

Upvotes: 0

Rahul Tripathi
Rahul Tripathi

Reputation: 172378

You can use the humanizr library and then simply try like this:

Console.WriteLine(123.ToWords());

or else you may try to look at this: Converting Numbers to Words

Upvotes: 1

Related Questions