Jump to content

Search the Community

Showing results for tags 'bitwise'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hi guys, Bitwise operations in Autoit is possible only till 32 bit integers, but sometimes WinAPI requires to process 64 bit vectors... so? So you can use this little UDF to handle properly those integers! Func _BitAND64($iValue1, $iValue2) If Not ((VarGetType($iValue1) = "Int64") Or (VarGetType($iValue2) = "Int64")) Then Return BitAND($iValue1, $iValue2) $iValue1 = __DecToBin64($iValue1) $iValue2 = __DecToBin64($iValue2) Local $aValueANDed[64], $i For $i = 0 To 63 $aValueANDed[$i] = ($iValue1[$i] And $iValue2[$i]) ? 1 : 0 Next Return __BinToDec64($aValueANDed) EndFunc ;==>_BitAND64 Func _BitOR64($iValue1, $iValue2) If Not ((VarGetType($iValue1) = "Int64") Or (VarGetType($iValue2) = "Int64")) Then Return BitOR($iValue1, $iValue2) $iValue1 = __DecToBin64($iValue1) $iValue2 = __DecToBin64($iValue2) Local $aValueORed[64], $i For $i = 0 To 63 $aValueORed[$i] = ($iValue1[$i] Or $iValue2[$i]) ? 1 : 0 Next Return __BinToDec64($aValueORed) EndFunc ;==>_BitOR64 Func _BitXOR64($iValue1, $iValue2) If Not ((VarGetType($iValue1) = "Int64") Or (VarGetType($iValue2) = "Int64")) Then Return BitXOR($iValue1, $iValue2) $iValue1 = __DecToBin64($iValue1) $iValue2 = __DecToBin64($iValue2) Local $aValueXORed[64], $i For $i = 0 To 63 $aValueXORed[$i] = (($iValue1[$i] And (Not $iValue2[$i])) Or ((Not $iValue1[$i]) And $iValue2)) ? 1 : 0 Next Return __BinToDec64($aValueXORed) EndFunc ;==>_BitXOR64 Func _BitNOT64($iValue) If Not (VarGetType($iValue) = "Int64") Then Return BitNOT($iValue) $iValue = __DecToBin64($iValue) For $i = 0 To 63 $iValue[$i] = Not $iValue[$i] Next Return __BinToDec64($iValue) EndFunc ;==>_BitNOT64 Func __DecToBin64($iDec) Local $tDec = DllStructCreate("int64 num"), $aBin[64], $bBit, $i $tDec.num = $iDec For $i = 0 To 63 $bBit = (Mod($tDec.num, 2) ? 1 : 0) $aBin[63 - $i] = $bBit $tDec.num = Floor($tDec.num / 2) Next Return $aBin EndFunc ;==>__DecToBin64 Func __BinToDec64($aBin) Local $tDec = DllStructCreate("int64 num"), $i If $aBin[0] Then $tDec.num += 0x8000000000000000 ;2^63 = 9223372036854775808, but for Autoit the world ends at 9223372036854775807 (2^63 - 1) For $i = 1 To 63 If $aBin[$i] Then $tDec.num += 2 ^ (63 - $i) Next Return $tDec.num EndFunc ;==>__BinToDec64 If you are working with unsigned 64 bit integers and these functions return a negative value, don't worry, bitwise operations come out well, but Autoit manages all numbers as signed integers.
×
×
  • Create New...