Jump to content
Sign in to follow this  
Fire

Qa: letters 2 decimal convert

Recommended Posts

Fire

Hi Great Community!

Guys i`m in stuck.Because i don`t know how to convert letters to decimal which will give me result like below:

http://www.pctools.com/guides/registry/detail/1281/

A: 1
 B: 2
 C: 4
 D: 8
 E: 16
 F: 32
 G: 64
 H: 128
 I: 256
 J: 512
 K: 1024
 L: 2048
 M: 4096
 N: 8192
 O: 16384
 P: 32768
 Q: 65536
 R: 131072
 S: 262144
 T: 524288
 U: 1048576
 V: 2097152
 W: 4194304
 X: 8388608
 Y: 16777216
 Z: 33554432
 ALL: 67108863

I try many ways how to convert letters to decimal but as result i cannot figure it out.I mean my result is wrong.

Guys I need only right direction.Thanks

and

Thanks in advance again.

Edited by Fire

[size="5"] [/size]

Share this post


Link to post
Share on other sites
Malkey

Here is another direction.

For $i = 0 To 25
    ConsoleWrite(ChrW($i + 65) & ": " & 2 ^ $i & @CRLF)
Next

ConsoleWrite("ALL: " & 2 ^ $i - 1 & @CRLF)
#cs
    A: 1
    B: 2
    C: 4
    D: 8
    E: 16
    F: 32
    G: 64
    H: 128
    I: 256
    J: 512
    K: 1024
    L: 2048
    M: 4096
    N: 8192
    O: 16384
    P: 32768
    Q: 65536
    R: 131072
    S: 262144
    T: 524288
    U: 1048576
    V: 2097152
    W: 4194304
    X: 8388608
    Y: 16777216
    Z: 33554432
    ALL: 67108863
#ce

Share this post


Link to post
Share on other sites
funkey

ConsoleWrite(_Letter2Dec("z") & @CR)
ConsoleWrite(_Letter2Dec("A") & @CR)

Func _Letter2Dec($sLetter)
    $sLetter = StringLeft(StringUpper($sLetter), 1)
    If Not StringIsAlpha($sLetter) Then Return SetError(1)
    Local $iAsc = Asc($sLetter) - 65
    Return 2^$iAsc
EndFunc


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites
Fire

Mat,Malkey,funkey Thanks so much Guys!

Solved.Thanks again.

Edited by Fire

[size="5"] [/size]

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  

×