Sign in to follow this  
Followers 0
sezercan19

IntToWord

32 posts in this topic

I need convert int to word any one can help me please ?

Share this post


Link to post
Share on other sites



I started to write a function for that at one time and never did complete it. Pretty simple up to the thousands. There are several javascript versions of it available by usinggoogle. just search for it and then convert that code to AutoIt.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

This is confusing. :blink:


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Maybe INT to DWORD?

Within the limits of AutoIt.

Number('0x' & Hex($Int))

i need Int To Word

like in vb6 WordFromInterger

Share this post


Link to post
Share on other sites

i need Int To Word

like in vb6 WordFromInterger

show an example scriptlet where this is needed so we can understand.

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

e.g vb6 code

WordFromInterger("1")

Share this post


Link to post
Share on other sites

e.g vb6 code

WordFromInterger("1")

And the result of that is?

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

And the result of that is?

returns 0100

e.g 2

WordfromInterger("12") returns 0C00

Edited by sezercan19

Share this post


Link to post
Share on other sites

I think he wants a numerical to return the string representation. 100 returns "one hundred", 10 returns "ten" etc. I was writing an app for printing cheques when I last played with that. He knows the VBS function for it but js has no such function. That's why I suggested he look up the js code snippets that are all over the place and do a conversion.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Probably slightly out... Uses short scale only as it's easy.

Local $iNum = 123456789876543
MsgBox(0, $iNum, NumToWord($iNum))

Func NumToWord($iNum)
    Local $asDigits[10] = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
    Local $asTeens[8] = ["eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "nineteen"]
    Local $asTens[9] = ["ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
    Local $asBig[22] = ["thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion", "septillion", "octillion", "nonillion", _
                        "decillion", "undecillion", "duodecillion", "tredecillion", "quattuordecillion", "quindecillion", "sexdecillion", "septendecillion", "octodecillion", "novemdecillion", "vigintillion"]

    Local $sRet = ""

    ; Very big numbers
    For $i = 22 To 1 Step - 1
        If $iNum >= 10 ^ ($i * 3) Then
            $iTemp = Floor($iNum / (10 ^ ($i * 3)))
            $iNum -= $iTemp * (10 ^ ($i * 3))
            $sRet &= NumToWord($iTemp) & " " & $asBig[$i - 1] & " "
        EndIf
    Next

    ; hundreds
    If $iNum >= 100 Then
        $iTemp = Floor($iNum / 100)
        $iNum -= $iTemp * 100
        $sRet &= NumToWord($iTemp) & " hundred and "
    EndIf

    If $iNum > 10 And $iNum < 20 Then
        $iTemp = Floor($iNum - 11)
        $iNum -= 11 + $iTemp
        $sRet &= $asTeens[$iTemp] & " "
    Else
        ; Tens
        If $iNum >= 10 Then
            $iTemp = Floor($iNum / 10)
            $iNum -= $iTemp * 10
            $sRet &= $asTens[$iTemp - 1] & " "
        EndIf

        ; Digits
        If $iNum >= 1 Then
            $sRet &= $asDigits[Floor($iNum)] & " "
            $iNum -= Floor($iNum)
        EndIf
    EndIf

    Return $sRet
EndFunc
Edited by Mat

Share this post


Link to post
Share on other sites

word = 2 byte :blink:

Share this post


Link to post
Share on other sites

i solved this with my udf :blink:

here is code

Func WordFromInteger($data)     
$WordFromInteger = Hex($data)   
If StringLen($WordFromInteger) = 1 Then         
$WordFromInteger = "0" & $WordFromInteger & "00"     
ElseIf StringLen($WordFromInteger) = 2 Then         
$WordFromInteger = $WordFromInteger & "00"     
ElseIf StringLen($WordFromInteger) = 3 Then         
$WordFromInteger = StringMid($WordFromInteger, 2, 2) & "0" & StringLeft($WordFromInteger, 1)    
ElseIf StringLen($WordFromInteger) = 4 Then         
$WordFromInteger = StringMid($WordFromInteger, 3, 2) & StringLeft($WordFromInteger, 2)     
EndIf   
Return $WordFromInteger     
EndFunc

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

i solved this with my udf ;)

here is code

Func WordFromInteger($data)     
$WordFromInteger = Hex($data)   
If StringLen($WordFromInteger) = 1 Then         
$WordFromInteger = "0" & $WordFromInteger & "00"     
ElseIf StringLen($WordFromInteger) = 2 Then         
$WordFromInteger = $WordFromInteger & "00"     
ElseIf StringLen($WordFromInteger) = 3 Then         
$WordFromInteger = StringMid($WordFromInteger, 2, 2) & "0" & StringLeft($WordFromInteger, 1)    
ElseIf StringLen($WordFromInteger) = 4 Then         
$WordFromInteger = StringMid($WordFromInteger, 3, 2) & StringLeft($WordFromInteger, 2)     
EndIf   
Return $WordFromInteger     
EndFunc

Congratulation, awesome UDF!

:blink:

Edited by Yashied

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

And there I was writing a big UDF to turn numbers into english words... :blink:

Func WordFromInteger($data)
    Return Hex($data, 8)
EndFunc

And heres my updated NumToWord. It now works well and does decimals.

link

You will here a lot of people on the next page complaining at how the function that was until just now posted here didn't work and I admit I left out a possibly important number by mistake. The one there works.

Edited by Mat

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

For those that like to extend NumToWord($iNum) to include "long scale" output.

http://en.wikipedia.org/wiki/Names_of_large_numbers#Extensions_of_the_standard_dictionary_numbers

(Org Example topic: NumToWord As in 100 = One hundred... *human* words...)

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Short scale is a lot easier, and is the standard now. Thanks for advertising :blink:

Share this post


Link to post
Share on other sites

Short scale is a lot easier, and is the standard now. Thanks for advertising ;)

Odd

If I try this with "Local $iNum = 18"

I get NineTeen !


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0