Jump to content

Base (Or Radix) Functions


torels
 Share

Recommended Posts

Hi There

I just wrote a script which turns a number in 10 basis in a number in any other basis ;)

Because of my bad english... just to make sure you understand what it's all about here is an example:

310 = 112 (2 basis is in other words Binary Code)

Func _Dec2Base($number, $base)
    local $nn, $reverse
    do
        $nn &= Mod($number,$base)
        $number = floor($number/$base)
    until $number <= 1
    $nn &= Mod($number,$base)
    For $i = 1 To StringLen($nn)
        $Reverse = StringMid($nn, $i, 1) & $Reverse
    Next
    Return $Reverse
EndFunc

Func _Base2Dec($number, $base)
    local $nn
    $pot = StringSplit($number,"")
    $len = StringLen($number) - 1
    
    for $i = $len to 0 step -1
        $nn += StringMid($number,$len - $i + 1,1) * ($base^$i)
    Next
    
    Return $nn
EndFunc

;example
MsgBox(0,"Example",_Dec2Base(4,2))

What do you think about it ?

Any suggestions ?

Edited by torels

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Hi There

I just wrote a script which turns a number in 10 basis in a number in any other basis ;)

Because of my bad english... just to make sure you understand what it's all about here is an example:

310 = 112 (2 basis is in other words Binary Code)

What do you think about it ?

Any suggestions ?

Ok but I don't see a code or an exe?

When the words fail... music speaks.

Link to comment
Share on other sites

OOPS ;)

:D

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

DOH!

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...