kaesereibe Posted July 17, 2014 Share Posted July 17, 2014 (edited) yet another int2hex() funtionThis example shows just a way to calculate int to hex manually.Otherwise please use the Hex() function.; AutoIt v3.3.12.0 #include <MsgBoxConstants.au3> MsgBox($MB_OK, "int2hex", int2hex(119) & " | " & int2hex(2147483647) & " | " & int2hex(4294967295)) Func int2hex($int) Local $h $BIT_BYTE = 8 ; bits per byte $HEX_BYTE = $BIT_BYTE / 4 ; hex digits in a byte $BIT_INT = 32 ; sizeof(int) $HEX_INT = $BIT_INT / ($BIT_BYTE / $HEX_BYTE) ; hex digits in an int While $HEX_INT ; while HEX_INT-- $HEX_INT -= 1 ; while HEX_INT-- $n = BitAnd(BitShift($int, ($HEX_INT * 4)), 0xf) ; (int >> (HEX_INT * 4)) & 0xf $h &= $n > 9 ? chr(0x37 + $n) : $n If $HEX_INT == 0 AND Floor($HEX_INT / $HEX_BYTE) == 0 Then ; if (HEX_INT == 0 && HEX_INT // HEX_BYTES == 0) $h &= " " EndIf WEnd Return "0x" & $h EndFunc ; ==> int2hex() Edited July 25, 2014 by kaesereibe BIN 2 DEC | ConvertTemp | DEC 2 BIN | GetWeekday | HEX 2 RGB | INT 2 HEX | QueryPerformance Link to comment Share on other sites More sharing options...
jchd Posted July 17, 2014 Share Posted July 17, 2014 Who need this (wrong) example to compete with the built-in Hex()? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
kaesereibe Posted July 17, 2014 Author Share Posted July 17, 2014 (edited) my goal was to calc this manual an not to use Hex() explain why its wrong Edited July 18, 2014 by jNizM BIN 2 DEC | ConvertTemp | DEC 2 BIN | GetWeekday | HEX 2 RGB | INT 2 HEX | QueryPerformance Link to comment Share on other sites More sharing options...
jchd Posted July 17, 2014 Share Posted July 17, 2014 This code won't handle int64 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
kaesereibe Posted July 17, 2014 Author Share Posted July 17, 2014 (edited) as you can read its for 32$BIT_INT = 32 ; sizeof(int) Edited July 17, 2014 by jNizM BIN 2 DEC | ConvertTemp | DEC 2 BIN | GetWeekday | HEX 2 RGB | INT 2 HEX | QueryPerformance Link to comment Share on other sites More sharing options...
jchd Posted July 17, 2014 Share Posted July 17, 2014 That means it's inferior to built-in Hex() function. So why bother creating it in the first place? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
kaesereibe Posted July 17, 2014 Author Share Posted July 17, 2014 (edited) Be a nice guy and do me a personal favor. Ignore my Topic pls. Because it's useless to discuss with you!!! It shows just another way without hex()thx bye bye Edited July 17, 2014 by jNizM BIN 2 DEC | ConvertTemp | DEC 2 BIN | GetWeekday | HEX 2 RGB | INT 2 HEX | QueryPerformance Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2014 Moderators Share Posted July 17, 2014 jNizM,Keep calm please. This is a semi-public forum - jchd has as much right to comment on your code as you have to post it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jchd Posted July 17, 2014 Share Posted July 17, 2014 jNizM, I'm not on a personal war against you or your posts. Just that I question the usefulness of code inferior to what comes standard with AutoIt. It's merely going to fool beginners. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
kaesereibe Posted July 18, 2014 Author Share Posted July 18, 2014 (edited) Changed first post (it was the way how you posted) Edited July 18, 2014 by kaesereibe BIN 2 DEC | ConvertTemp | DEC 2 BIN | GetWeekday | HEX 2 RGB | INT 2 HEX | QueryPerformance Link to comment Share on other sites More sharing options...
Mat Posted July 18, 2014 Share Posted July 18, 2014 Here's generic base conversion functions that I've been using for years: https://gist.github.com/MattDiesel/5813398 AutoIt Project Listing Link to comment Share on other sites More sharing options...
kaesereibe Posted July 18, 2014 Author Share Posted July 18, 2014 same here:#include <MsgBoxConstants.au3> Func _TranslateBase($sNumber, $iOldBase = 10, $iNewBase = 2) ; _TranslateBase() by eukalyptus If $iOldBase < 2 Or $iOldBase > 128 Or $iNewBase < 2 Or $iNewBase > 128 Then Return SetError(1, 1, False) Local $iNum, $aRes, $tChr = DllStructCreate("char[64];") If $iOldBase <> 10 Then $aRes = DllCall("msvcrt.dll", "uint64:cdecl", "_strtoui64", "str", $sNumber, "ptr", 0, "int", $iOldBase) If @error Then Return SetError(1, 2, False) $iNum = $aRes[0] Else $iNum = Int($sNumber) EndIf $aRes = DllCall("msvcrt.dll", "ptr:cdecl", "_i64toa", "int64", $iNum, "ptr", DllStructGetPtr($tChr), "int", $iNewBase) If @error Then Return SetError(1, 3, False) Return DllStructGetData($tChr, 1) EndFunc ;==>_TranslateBase $decToBin = _TranslateBase(111, 10, 2) $binToDec = _TranslateBase(01101111, 2, 10) MsgBox(4096, "TranslateBase", "Decimal to Binary:" & @CRLF & "111 to " & $decToBin) MsgBox(4096, "TranslateBase", "Binary to Decimal:" & @CRLF & "01101111 to " & $binToDec) BIN 2 DEC | ConvertTemp | DEC 2 BIN | GetWeekday | HEX 2 RGB | INT 2 HEX | QueryPerformance Link to comment Share on other sites More sharing options...
czardas Posted July 18, 2014 Share Posted July 18, 2014 (edited) It's good to try out things for yourself and learn through this experience. I consider that a valid reason to post such an example, even if there are more flexible versions available. By this process it may be possible to learn about design flaws and optimization proceedures. While I have received criticism for several of my own posts, it has mainly been to my benefit in the long run. I don't always listen to everyone, but I can assure you that MVPs such as Mat and JCHD don't normally comment unless they feel there is justification. There is one thing I am wondering about: I'm not sure why you added this. ==> If $HEX_INT == 0 AND Floor($HEX_INT / $HEX_BYTE) == 0 Then ; if (HEX_INT == 0 && HEX_INT // HEX_BYTES == 0) $h &= " " EndIf ; I urge you to continue trying out your own ideas, providing you also research tried and tested methods; and I wish you good luck with your code projects. Edited July 18, 2014 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
guinness Posted July 18, 2014 Share Posted July 18, 2014 Nice gists Mat. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now