Click here to Skip to main content
15,920,956 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Converting numbers into English Pin
Mark_Wallace25-Sep-13 21:34
Mark_Wallace25-Sep-13 21:34 
GeneralRe: Converting numbers into English Pin
Dan Sutton26-Sep-13 4:55
Dan Sutton26-Sep-13 4:55 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult26-Sep-13 13:48
mvePIEBALDconsult26-Sep-13 13:48 
GeneralRe: Converting numbers into English Pin
NormDroid25-Sep-13 23:53
professionalNormDroid25-Sep-13 23:53 
GeneralRe: Converting numbers into English Pin
Dan Sutton26-Sep-13 4:55
Dan Sutton26-Sep-13 4:55 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult26-Sep-13 13:53
mvePIEBALDconsult26-Sep-13 13:53 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult26-Sep-13 13:48
mvePIEBALDconsult26-Sep-13 13:48 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult27-Sep-13 19:50
mvePIEBALDconsult27-Sep-13 19:50 
Thanks for a few days' exercise. I made one that can be used like:

2345L.ToString<ShortScale>() ==> Two Thousand Three Hundred Forty-Five

Where ShortScale is:

public enum ShortScale : long
{
    Zero = 0 , One = 1 , Two = 2 , Three = 3 , Four = 4 , Five = 5 , Six = 6 , Seven = 7 , Eight = 8  
    , Nine = 9 , Ten = 10 , Eleven = 11 , Twelve = 12 , Thirteen = 13 , Fourteen = 14 , Fifteen = 15  
    , Sixteen = 16 , Seventeen = 17 , Eighteen = 18 , Nineteen = 19 
            
    , [PIEBALD.Types.NumNuts.HyphenatedAttribute] Twenty   = 20  
...            
    , [PIEBALD.Types.NumNuts.CountedAttribute] Hundred     = 100                   
...  
}


I also have an enum that will yield Twenty-Three Hundred Forty-Five, but it needs work.


Here's another:

2345L.ToString<Roman>() ==> MMCCCXLV

public enum Roman
{
    Nulla = 0 
    , [PIEBALD.Types.NumNuts.RepeatedAttribute] I  = 1     
    , [PIEBALD.Types.NumNuts.RepeatedAttribute] IV = 4    
    , [PIEBALD.Types.NumNuts.RepeatedAttribute] V  = 5     
    , [PIEBALD.Types.NumNuts.RepeatedAttribute] IX = 9    
    , [PIEBALD.Types.NumNuts.RepeatedAttribute] X  = 10    
...
}


But this technique tops out at Quintillion (short scale) or Trillion (long scale), so another technique would be necessary to work with greater numbers.
It should be possible to define a class of BigInteger constants and use that instead.


Added:

public sealed class TestClass
{
    public static readonly System.Numerics.BigInteger Zero   = 0 ;
    public static readonly System.Numerics.BigInteger One    = 1 ;
...
    [PIEBALD.Types.NumNuts.HyphenatedAttribute]
    public static readonly System.Numerics.BigInteger Twenty  = 20 ;
...
    [PIEBALD.Types.NumNuts.CountedAttribute]
    public static readonly System.Numerics.BigInteger Hundred     = 100 ;
...
    [PIEBALD.Types.NumNuts.CountedAttribute]
    public static readonly System.Numerics.BigInteger Decillion   = Thousand * Nonillion ;
...
}


modified 30-Sep-13 23:49pm.

GeneralRe: Converting numbers into English Pin
Dan Sutton1-Oct-13 8:32
Dan Sutton1-Oct-13 8:32 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult1-Oct-13 10:44
mvePIEBALDconsult1-Oct-13 10:44 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult2-Oct-13 3:38
mvePIEBALDconsult2-Oct-13 3:38 
GeneralRe: Converting numbers into English Pin
Dan Sutton2-Oct-13 5:58
Dan Sutton2-Oct-13 5:58 
QuestionThinking about starting a public project Pin
Christopher Stevenson25-Sep-13 12:38
professionalChristopher Stevenson25-Sep-13 12:38 
AnswerRe: Thinking about starting a public project Pin
Pete O'Hanlon25-Sep-13 12:44
mvePete O'Hanlon25-Sep-13 12:44 
GeneralRe: Thinking about starting a public project Pin
Christopher Stevenson25-Sep-13 14:41
professionalChristopher Stevenson25-Sep-13 14:41 
GeneralRe: Thinking about starting a public project Pin
Mycroft Holmes25-Sep-13 16:08
professionalMycroft Holmes25-Sep-13 16:08 
GeneralRe: Thinking about starting a public project Pin
Christopher Stevenson25-Sep-13 16:26
professionalChristopher Stevenson25-Sep-13 16:26 
GeneralRe: Thinking about starting a public project Pin
Mycroft Holmes25-Sep-13 16:58
professionalMycroft Holmes25-Sep-13 16:58 
GeneralRe: Thinking about starting a public project Pin
Christopher Stevenson25-Sep-13 17:10
professionalChristopher Stevenson25-Sep-13 17:10 
GeneralRe: Thinking about starting a public project Pin
Mycroft Holmes25-Sep-13 17:26
professionalMycroft Holmes25-Sep-13 17:26 
GeneralRe: Thinking about starting a public project Pin
Christopher Stevenson25-Sep-13 19:33
professionalChristopher Stevenson25-Sep-13 19:33 
AnswerRe: Thinking about starting a public project Pin
Marc Clifton25-Sep-13 12:56
mvaMarc Clifton25-Sep-13 12:56 
AnswerRe: Thinking about starting a public project Pin
Akinmade Bond25-Sep-13 13:24
professionalAkinmade Bond25-Sep-13 13:24 
GeneralRe: Thinking about starting a public project Pin
PIEBALDconsult25-Sep-13 13:57
mvePIEBALDconsult25-Sep-13 13:57 
AnswerRe: Thinking about starting a public project Pin
Bassam Abdul-Baki26-Sep-13 0:26
professionalBassam Abdul-Baki26-Sep-13 0:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.