Sign in to follow this  
Followers 0
Mikon

UDF _HexLen

1 post in this topic

i thougth this could be usefull for someone

Func _HexLen($Number)
    If Not IsNumber($Number) Then
        SetError(1)
        Return 0
    ElseIf $Number = 0 Then
        Return 1
    Else
        If $Number < 0 Then $Number = $Number * -1
        Return Int(Log($Number)/Log(16))+1
    EndIf
EndFunc

example:

$aNumber = Random(1, 1000);you dont know the value of $aNumber and so you dont know the second parameter for the Hex-function
$Hex = Hex($aNumber, _HexLen($aNumber))
MsgBox(0, "Example for " & $aNumber, $Hex)

you can modify this with replacing the 16 in line 9 with a 2 for calculating the length of a binary number (just for example)

Mikon

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