Popular Post Trong Posted August 23 Popular Post Posted August 23 (edited) I had a dissatisfaction with IsNumber so this function was born: expandcollapse popup; ========================================================================================= ; UDF: DataTypeChecker.au3 (strict-hex + numeric formats + IEEE754 + self-test: _RunSelfTest() ) ; Author: Dao Van Trong - TRONG.PRO ; Notes: ; - Type codes start at 1 (String = 1). IEEE-754 subtypes continue up to 24. ; - Unknown returns 0 (no numeric code assigned). ; - String detection order: Hex (0x... or bare even-length [0-9A-Fa-f]) → ; Numeric (US/EU/Thousands/Simple-EU) → Boolean-like → fallback String. ; - HWND is checked before Ptr to avoid misclassification. ; ========================================================================================= ; -------- Global Type Codes (1..24) -------- Global Const $TYPE_STRING = 1 Global Const $TYPE_INT32 = 2 Global Const $TYPE_INT64 = 3 Global Const $TYPE_DOUBLE = 4 Global Const $TYPE_BINARY = 5 Global Const $TYPE_BOOLEAN = 6 Global Const $TYPE_ARRAY = 7 Global Const $TYPE_MAP = 8 Global Const $TYPE_PTR = 9 Global Const $TYPE_STRUCT = 10 Global Const $TYPE_HWND = 11 Global Const $TYPE_OBJECT = 12 Global Const $TYPE_KEYWORD = 13 Global Const $TYPE_FUNCTION = 14 Global Const $TYPE_USERFUNCTION = 15 ; IEEE-754 sub-categories for Double Global Const $TYPE_POS_ZERO = 16 Global Const $TYPE_NEG_ZERO = 17 Global Const $TYPE_DENORMAL_POS = 18 Global Const $TYPE_DENORMAL_NEG = 19 Global Const $TYPE_NORMAL_POS = 20 Global Const $TYPE_NORMAL_NEG = 21 Global Const $TYPE_POS_INFINITY = 22 Global Const $TYPE_NEG_INFINITY = 23 Global Const $TYPE_NAN = 24 ; Unknown uses 0 (no constant) ; -------- Code → Name -------- Func _GetDataTypeName($i) Select Case $i = $TYPE_STRING Return "String" Case $i = $TYPE_INT32 Return "Int32" Case $i = $TYPE_INT64 Return "Int64" Case $i = $TYPE_DOUBLE Return "Double/Float" Case $i = $TYPE_BINARY Return "Binary/Hex" Case $i = $TYPE_BOOLEAN Return "Boolean" Case $i = $TYPE_ARRAY Return "Array" Case $i = $TYPE_MAP Return "Map" Case $i = $TYPE_PTR Return "Pointer" Case $i = $TYPE_STRUCT Return "DLL Struct" Case $i = $TYPE_HWND Return "Window Handle" Case $i = $TYPE_OBJECT Return "Object" Case $i = $TYPE_KEYWORD Return "Keyword" Case $i = $TYPE_FUNCTION Return "Function" Case $i = $TYPE_USERFUNCTION Return "UserFunction" Case $i = $TYPE_POS_ZERO Return "+Zero" Case $i = $TYPE_NEG_ZERO Return "-Zero" Case $i = $TYPE_DENORMAL_POS Return "deNormal (+)" Case $i = $TYPE_DENORMAL_NEG Return "deNormal (−)" Case $i = $TYPE_NORMAL_POS Return "Normal (+)" Case $i = $TYPE_NORMAL_NEG Return "Normal (−)" Case $i = $TYPE_POS_INFINITY Return "+Infinity" Case $i = $TYPE_NEG_INFINITY Return "-Infinity" Case $i = $TYPE_NAN Return "NaN" Case Else Return "Unknown" EndSelect EndFunc ;==>_GetDataTypeName ; -------- IEEE-754 classifier for Double (robust for 64-bit via hi/low dwords) -------- Func _CheckIEEE754Category($dVal) ; Overlay: write the double, then read two dwords at the same address Local $tDouble = DllStructCreate("double") DllStructSetData($tDouble, 1, $dVal) Local $p = DllStructGetPtr($tDouble) Local $tWords = DllStructCreate("dword;dword", $p) ; [1]=low, [2]=high on little-endian Local $low = DllStructGetData($tWords, 1) Local $high = DllStructGetData($tWords, 2) Local $sign = BitAND(BitShift($high, 31), 1) Local $exp = BitAND(BitShift($high, 20), 0x7FF) Local $fracHigh = BitAND($high, 0x000FFFFF) Local $fracLow = $low Local $fracIsZero = ($fracHigh = 0 And $fracLow = 0) If $exp = 0 Then If $fracIsZero Then Return ($sign ? $TYPE_NEG_ZERO : $TYPE_POS_ZERO) Else Return ($sign ? $TYPE_DENORMAL_NEG : $TYPE_DENORMAL_POS) EndIf ElseIf $exp = 0x7FF Then If $fracIsZero Then Return ($sign ? $TYPE_NEG_INFINITY : $TYPE_POS_INFINITY) Else Return $TYPE_NAN EndIf Else Return ($sign ? $TYPE_NORMAL_NEG : $TYPE_NORMAL_POS) EndIf EndFunc ;==>_CheckIEEE754Category ; -------- Decide Int32 vs Int64 by range -------- Func _IntCodeFromNumber($n) If $n >= -2147483648 And $n <= 2147483647 Then Return $TYPE_INT32 Else Return $TYPE_INT64 EndIf EndFunc ;==>_IntCodeFromNumber ; -------- Normalize & classify numeric strings -------- ; Returns: type code (2/3 for ints OR IEEE-754 sub-codes 16..24 for doubles) Func _ParseNumericString($s) ; US: 1,234.56 → remove commas, parse with dot If StringRegExp($s, '^[+-]?\d{1,3}(,\d{3})*(\.\d+)?$') Then Local $u = StringReplace($s, ",", "") If StringInStr($u, ".") Then Return _CheckIEEE754Category(Number($u)) Else ; For grouped integers (US), we follow user's expectation: ; treat as Double category (Normal +/-) rather than Int32/Int64 Return _CheckIEEE754Category(Number($u)) EndIf EndIf ; EU: 1.234,56 → remove dots, replace comma with dot If StringRegExp($s, '^[+-]?\d{1,3}(\.\d{3})*(,\d+)?$') Then Local $e = StringReplace(StringReplace($s, ".", ""), ",", ".") If StringInStr($s, ",") Then Return _CheckIEEE754Category(Number($e)) Else ; Grouped integer (EU) → follow same rule: classify via IEEE-754 Return _CheckIEEE754Category(Number($e)) EndIf EndIf ; Thousands only: 1,234 or 1.234 → strip separators If StringRegExp($s, '^[+-]?\d{1,3}([,\.]\d{3})+$') Then Local $t = StringReplace(StringReplace($s, ",", ""), ".", "") ; Per user's expected results: treat grouped integer as Double category Return _CheckIEEE754Category(Number($t)) EndIf ; Simple EU decimals: 123,45 → replace comma with dot If StringRegExp($s, '^[+-]?\d+,\d+$') Then Local $d = StringReplace($s, ",", ".") Return _CheckIEEE754Category(Number($d)) EndIf ; Plain ints/floats (no separators) If StringIsInt($s) Then Return _IntCodeFromNumber(Number($s)) If StringIsFloat($s) Then Return _CheckIEEE754Category(Number($s)) ; Not numeric Return 0 EndFunc ;==>_ParseNumericString ; -------- Parse strings: Hex → Numeric → Boolean-like → String -------- Func _ParseStringValue($s) $s = StringStripWS($s, 8) ; Hex with prefix 0x, body must have even length If StringRegExp($s, "^0[xX][0-9A-Fa-f]+$") Then Local $hexBody = StringMid($s, 3) If Mod(StringLen($hexBody), 2) = 0 Then Return $TYPE_BINARY EndIf ; Bare hex (0-9 A-F), even length accepted as hex (as requested) If StringRegExp($s, "^[0-9A-Fa-f]+$") Then If Mod(StringLen($s), 2) = 0 Then Return $TYPE_BINARY EndIf ; Numeric formats Local $numCode = _ParseNumericString($s) If $numCode <> 0 Then Return $numCode ; Boolean-like strings Switch StringLower($s) Case "true", "false" Return $TYPE_BOOLEAN EndSwitch ; Fallback string Return $TYPE_STRING EndFunc ;==>_ParseStringValue ; -------- Public: get type code for any value -------- Func _GetDataType($v) ; AutoIt-specific first (order matters) If IsArray($v) Then Return $TYPE_ARRAY If IsMap($v) Then Return $TYPE_MAP If IsHWnd($v) Then Return $TYPE_HWND If IsPtr($v) Then Return $TYPE_PTR If IsDllStruct($v) Then Return $TYPE_STRUCT If IsObj($v) Then Return $TYPE_OBJECT If IsKeyword($v) Then Return $TYPE_KEYWORD Local $sType = VarGetType($v) If IsFunc($v) Then If $sType = "UserFunction" Then Return $TYPE_USERFUNCTION Else Return $TYPE_FUNCTION EndIf EndIf ; Native primitives If $sType = "Int32" Then Return $TYPE_INT32 If $sType = "Int64" Then Return $TYPE_INT64 If $sType = "Double" Then Return _CheckIEEE754Category($v) If IsBinary($v) Then Return $TYPE_BINARY If IsBool($v) Then Return $TYPE_BOOLEAN ; Strings If IsString($v) Then Return _ParseStringValue($v) ; Unknown Return 0 EndFunc ;==>_GetDataType ; -------- Helper: is any numeric type? (native or string-based) -------- Func _IsNumber($v) Local $c = _GetDataType($v) Return ($c = $TYPE_INT32 Or $c = $TYPE_INT64 Or $c = $TYPE_DOUBLE Or _ $c = $TYPE_POS_ZERO Or $c = $TYPE_NEG_ZERO Or _ $c = $TYPE_DENORMAL_POS Or $c = $TYPE_DENORMAL_NEG Or _ $c = $TYPE_NORMAL_POS Or $c = $TYPE_NORMAL_NEG Or _ $c = $TYPE_POS_INFINITY Or $c = $TYPE_NEG_INFINITY Or _ $c = $TYPE_NAN) EndFunc ;==>_IsNumber ; ========================================================================================= ; SELF-TEST (English logs, prefixes: '+' OK, '!' ERROR, '-' INFO) ; ========================================================================================= Func _AddTest(ByRef $arr, $val, $expectedName, $label) ReDim $arr[UBound($arr) + 1][3] $arr[UBound($arr) - 1][0] = $val $arr[UBound($arr) - 1][1] = $expectedName $arr[UBound($arr) - 1][2] = $label EndFunc ;==>_AddTest Func __TestFunc() Return 1 EndFunc ;==>__TestFunc Func _RunSelfTest() ConsoleWrite("- Starting self-test..." & @CRLF) Local $tests[0][3] ; --- String fallback --- _AddTest($tests, "Hello", "String", "Plain string") ; Per requirement: bare [0-9A-F] with even length is HEX _AddTest($tests, "123ABC", "Binary/Hex", "Bare hex (even)") ; --- Int32 / Int64 --- _AddTest($tests, 42, "Int32", "Integer") _AddTest($tests, -999, "Int32", "Negative int") _AddTest($tests, 9223372036854775807, "Int64", "Max Int64") _AddTest($tests, -9223372036854775808, "Int64", "Min Int64") ; --- Double / IEEE754 normal --- _AddTest($tests, 3.14159, "Normal (+)", "Positive double") _AddTest($tests, -2.71828, "Normal (−)", "Negative double") ; --- Binary/Hex --- _AddTest($tests, "0x1A2B", "Binary/Hex", "Prefixed hex string") _AddTest($tests, "DEADBEEF", "Binary/Hex", "Bare hex string") ; --- Boolean --- _AddTest($tests, True, "Boolean", "True literal") _AddTest($tests, "false", "Boolean", "Boolean-like string") ; --- Array --- Local $arr[2] = [1, 2] _AddTest($tests, $arr, "Array", "Simple array") ; --- Map (correct syntax) --- Local $mMap[] $mMap["Key"] = "Value" _AddTest($tests, $mMap, "Map", "Map object") ; --- Ptr --- Local $p = Ptr(0x123456) _AddTest($tests, $p, "Pointer", "Pointer value") ; --- DllStruct --- Local $st = DllStructCreate("int;char[4]") _AddTest($tests, $st, "DLL Struct", "DllStruct sample") ; --- HWND (create GUI to ensure valid handle) --- Local $hGUI = GUICreate("DT Test", 1, 1, -100, -100) GUISetState(@SW_SHOW, $hGUI) _AddTest($tests, $hGUI, "Window Handle", "GUI handle") ; --- Object --- Local $o = ObjCreate("Scripting.Dictionary") _AddTest($tests, $o, "Object", "COM object") ; --- Keyword --- _AddTest($tests, Default, "Keyword", "Keyword Default") _AddTest($tests, Null, "Keyword", "Keyword Null") ; --- Function & UserFunction --- _AddTest($tests, Eval, "Function", "Builtin function") _AddTest($tests, __TestFunc, "UserFunction", "User-defined function") ; --- IEEE754 specials --- _AddTest($tests, +0.0, "+Zero", "Positive zero") _AddTest($tests, -0.0, "-Zero", "Negative zero") _AddTest($tests, (1.0 / 0.0), "+Infinity", "Positive infinity") _AddTest($tests, (-1.0 / 0.0), "-Infinity", "Negative infinity") _AddTest($tests, (0.0 / 0.0), "NaN", "Not-a-Number") ; --- Numeric strings: US/EU/Thousands/Simple-EU --- _AddTest($tests, "1,234.56", "Normal (+)", "US numeric string") _AddTest($tests, "1.234,56", "Normal (+)", "EU numeric string") _AddTest($tests, "1,234", "Normal (+)", "Thousand separator comma") _AddTest($tests, "1.234", "Normal (+)", "Thousand separator dot") _AddTest($tests, "123,45", "Normal (+)", "EU decimal comma") ; --- Run all --- For $i = 0 To UBound($tests) - 1 Local $input = $tests[$i][0] Local $expected = $tests[$i][1] Local $label = $tests[$i][2] Local $code = _GetDataType($input) Local $got = _GetDataTypeName($code) If $got = $expected Then ConsoleWrite("- " & '_IsNumber(' & $input & ") -> " & _IsNumber($input) & @CRLF) ConsoleWrite("+ " & $label & ' "' & $input & '" -> (' & $code & ') ' & $got & @CRLF) Else ConsoleWrite("! " & $label & ' "' & $input & '" -> (' & $code & ') ' & $got & " | Expected: " & $expected & @CRLF) EndIf Next ConsoleWrite("- Self-test complete." & @CRLF) ; Clean up GUI created for HWND test GUIDelete($hGUI) EndFunc ;==>_RunSelfTest ; ========================================================================================= ; Self-test routine: kiểm tra các giá trị mẫu và in PASS/FAIL ; ========================================================================================= Func _RunSelfTest2() Local $tests = [ _ ["String literal", "Hello", $TYPE_STRING], _ ["Int32 literal", 123, $TYPE_INT32], _ ["Int64 literal", 5000000000, $TYPE_INT64], _ ["Double normal +", 3.14, $TYPE_NORMAL_POS], _ ["Double normal −", -2.5, $TYPE_NORMAL_NEG], _ ["+Zero (double)", 0.0, $TYPE_POS_ZERO], _ ["-Zero (double)", -0.0, $TYPE_NEG_ZERO], _ ["Subnormal", Number("1e-320"), $TYPE_DENORMAL_POS], _ ["+Infinity", 1 / 0, $TYPE_POS_INFINITY], _ ["-Infinity", -1 / 0, $TYPE_NEG_INFINITY], _ ["NaN", 0 / 0, $TYPE_NAN], _ ["Hex 0x…", "0x1A2B", $TYPE_BINARY], _ ["Bare hex", "FACE", $TYPE_BINARY], _ ["US number", "1,234.56", $TYPE_NORMAL_POS], _ ["EU number", "1.234,56", $TYPE_NORMAL_POS], _ ["Thou only", "1,234", $TYPE_NORMAL_POS], _ ["Simple EU dec", "123,45", $TYPE_NORMAL_POS], _ ["Bool-like true", "true", $TYPE_BOOLEAN], _ ["Bool-like false", "false", $TYPE_BOOLEAN] _ ] Local $allOK = True ConsoleWrite(@CRLF & "---- Running DataTypeChecker Self-Test ----" & @CRLF) For $i = 0 To UBound($tests) - 1 Local $desc = $tests[$i][0] Local $val = $tests[$i][1] Local $exp = $tests[$i][2] Local $got = _GetDataType($val) Local $name = _GetDataTypeName($got) If $got = $exp Then ConsoleWrite("- _IsNumber(" & $val & ') -> ' & _IsNumber($val) & @CRLF) ConsoleWrite("+ PASS: " & $desc & ' "' & $val & '" -> ' & $name & " (" & $got & ")" & @CRLF) Else ConsoleWrite("! FAIL: " & $desc & ' "' & $val & '" -> Expected ' & _ _GetDataTypeName($exp) & " (" & $exp & "), Got " & _ $name & " (" & $got & ")" & @CRLF) $allOK = False EndIf Next ConsoleWrite("---- Self-Test " & ($allOK ? "+ PASSED" : "! FAILED") & " ----" & @CRLF & @CRLF) Return $allOK EndFunc ;==>_RunSelfTest2 ; Uncomment to run self-test on execute ; _RunSelfTest() ; _RunSelfTest2() Edited Sunday at 08:42 PM by Trong add IEEE754 Category Musashi, mLipok, WildByDesign and 2 others 5 Regards,
jchd Posted August 23 Posted August 23 (edited) You can add 3 AutoIt types: Keyword, Function and UserFunction. Also you can differentiate between Int32, Int64, Double and float signals. Edited August 23 by jchd Trong 1 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)
jchd Posted August 24 Posted August 24 (edited) If you need/want to characterize floats beyond just being of datatype "double", you can pick ideas from this code: expandcollapse popupLocal $a = [ _ [0xfff0000000000000, "-infinity"], _ ; 1 11111111111 0000000000000000000000000000000000000000000000000000 ⎫ [0xffefffffffffffff, "smallest negative normal"], _ ; 1 11111111110 1111111111111111111111111111111111111111111111111111 ⎪ [0x8010000000000000, "largest negative normal"], _ ; 1 00000000001 0000000000000000000000000000000000000000000000000000 ⎪ [0x8000000000000000, "negative zero"], _ ; 1 00000000000 0000000000000000000000000000000000000000000000000000 ⎪ [0x0000000000000000, "positive zero"], _ ; 0 00000000000 0000000000000000000000000000000000000000000000000000 ⎬ Numbers you can deal with [0x0010000000000000, "smallest positive normal"], _ ; 0 00000000001 0000000000000000000000000000000000000000000000000000 ⎪ [0x7fefffffffffffff, "largest positive normal"], _ ; 0 11111111110 1111111111111111111111111111111111111111111111111111 ⎪ [0x7ff0000000000000, "+infinity"], _ ; 0 11111111111 0000000000000000000000000000000000000000000000000000 ⎭ [0x800fffffffffffff, "smallest negative denormal"], _ ; 1 00000000000 1111111111111111111111111111111111111111111111111111 ⎫ [0x8000000000000001, "largest negative denormal"], _ ; 1 00000000000 0000000000000000000000000000000000000000000000000001 ⎬ Numbers best avoided unless [0x0000000000000001, "smallest positive denormal"], _ ; 0 00000000000 0000000000000000000000000000000000000000000000000001 ⎪ dealing with extra-small values [0x000fffffffffffff, "largest positive denormal"], _ ; 0 00000000000 1111111111111111111111111111111111111111111111111111 ⎭ [0xfff8000000000001, "-NAN (quiet, denormal)"], _ ; 1 11111111111 1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x >= 1 ⎫ [0xfff0000000000001, "-NAN (signaling, denormal)"], _ ; 1 11111111111 00xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x >= 1 ⎪ [0xfff4000000000001, "-NAN (signaling, normal)"], _ ; 1 11111111111 0100000000000000000000000000000000000000000000000000 ⎪ [0x7ff4000000000001, "+NAN (signaling, normal)"], _ ; 0 11111111111 0100000000000000000000000000000000000000000000000000 ⎬ You shouldn't get those [0x7ff8000000000001, "+NAN (quiet, denormal)"], _ ; 0 11111111111 1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x >= 1 ⎪ [0x7ff0000000000001, "+NAN (signaling, denormal)"], _ ; 0 11111111111 00xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x >= 1 ⎭ [0xfff8000000000000, " NAN (indeterminate)"] _ ; 1 11111111111 1000000000000000000000000000000000000000000000000000 ◀ You made a big mistake ] ConsoleWrite("Ranges of double values" & @LF) Local $t = DllStructCreate("int64") Local $u = DllStructCreate("double", DllStructGetPtr($t)) Local $v For $n = 0 To UBound($a) - 1 DllStructSetData($t, 1, $a[$n][0]) $v = DllStructGetData($u, 1) ConsoleWrite(StringFormat("%s%23s\t%s\n", VarGetType($v), $v, $a[$n][1])) Next ConsoleWrite(@LF & "FP zeroes are signed !" & @LF) ConsoleWrite(" 0/3" & @TAB & (0/3) & @LF) ConsoleWrite("-0/-3" & @TAB & (-0/-3) & @LF) ConsoleWrite(" 0/-3" & @TAB & (0/-3) & @LF) ConsoleWrite("-0/3" & @TAB & (-0/3) & @LF) ConsoleWrite("Yet (hopefully)" & @LF) ConsoleWrite("0/-3 = 0/3" & @TAB & (0/-3 = 0/3) & @LF) ConsoleWrite("0/-3 = 0" & @TAB & (0/3 = 0) & @LF) ConsoleWrite(@LF & "Infinities compute (but if you get there, you are mostly stuck!)" & @LF) Local Const $PI = 3.141592653589793 ConsoleWrite("3/0" & @TAB & @TAB & (3/0) & @LF) ConsoleWrite("3/0 + 100" & @TAB & (3/0 + 100) & @LF) ConsoleWrite("(3/0) / 2" & @TAB & ((3/0) / 2) & @LF) ConsoleWrite("(3/0) ^ 2" & @TAB & ((3/0) ^ 2) & @LF) ConsoleWrite("-3/0" & @TAB & @TAB & (-3/0) & @LF) ConsoleWrite("-3/0 + 100" & @TAB & (-3/0 + 100) & @LF) ConsoleWrite("(-3/0) / 2" & @TAB & ((-3/0) / 2) & @LF) ConsoleWrite("(-3/0) ^ 2" & @TAB & ((-3/0) ^ 2) & @LF) ConsoleWrite("(-3/0) ^ 5" & @TAB & ((-3/0) ^ 5) & @LF) ConsoleWrite("Log(1/0)" & @TAB & Log(1/0) & @LF) ConsoleWrite("Exp(1/0)" & @TAB & Exp(1/0) & @LF) ConsoleWrite("Tan($Pi/2)" & @TAB & Tan($Pi/2) & @TAB & "<-- should be 'inf'" & @LF) ConsoleWrite("Tan(-$Pi/2)" & @TAB & Tan(-$Pi/2) & @TAB & "<-- should be '-inf'" & @LF) ConsoleWrite("ATan(1/0)" & @TAB & ATan(1/0) & @TAB & @TAB & "<-- Pi/2" & @LF) ConsoleWrite("ATan(-1/0)" & @TAB & ATan(-1/0) & @TAB & "<-- -Pi/2" & @LF) ConsoleWrite("1/(1/0)" & @TAB & @TAB & 1/(1/0) & @LF) ConsoleWrite("-1/(1/0)" & @TAB & -1/(1/0) & @LF) ConsoleWrite("1/(-1/0)" & @TAB & 1/(-1/0) & @LF) ConsoleWrite("-1/(-1/0)" & @TAB & -1/(-1/0) & @LF) ConsoleWrite("0^0)" & @TAB & @TAB & 0^0 & @TAB & @TAB & @TAB & "<-- NOT indeterminate in FP" & @LF) ConsoleWrite("(1/0)^0" & @TAB & @TAB & (1/0)^0 & @TAB & @TAB & @TAB & "<-- NOT indeterminate in FP" & @LF) ConsoleWrite(@LF & "Indeterminate forms" & @LF) Local $ind = [ _ ["0/0", 0/0], _ ["0*(1/0)", 0*(1/0)], _ ["0*(-1/0)", 0*(-1/0)], _ ["(1/0)-(1/0)", (1/0)-(1/0)], _ ["(-1/0)-(-1/0)", (-1/0)-(-1/0)], _ ["(1/0)+(-1/0)", (1/0)+(-1/0)], _ ["(-1/0)+(1/0)", (-1/0)+(1/0)], _ ["1^(1/0)", 1^(1/0)], _ ["1^(-1/0)", 1^(-1/0)], _ ["-1^(1/0)", -1^(1/0)], _ ["-1^(-1/0)", -1^(-1/0)], _ ["Cos(1/0)", Cos(1/0)], _ ["Sin(1/0)", Sin(1/0)], _ ["ACos(5)", ACos(5)], _ ["ASin(5)", ASin(5)], _ ["Sqrt(-1)", Sqrt(-1)], _ ["Log(-1)", Log(-1)] _ ] For $i = 0 To UBound($ind) - 1 ConsoleWrite(StringFormat("%-15s\t%s\t%f\n", $ind[$i][0], VarGetType($ind[$i][1]), $ind[$i][1])) Next ConsoleWrite(@LF & "NANs never compare !" & @LF) ConsoleWrite("0/0 > 0" & @TAB & @TAB & (0/0 > 0) & @LF) ConsoleWrite("0/0 = 0" & @TAB & @TAB & (0/0 = 0) & @LF) ConsoleWrite("0/0 < 0" & @TAB & @TAB & (0/0 < 0) & @LF) ConsoleWrite("0/0 > -0/0" & @TAB & (0/0 > -0/0) & @LF) ConsoleWrite("0/0 = -0/0" & @TAB & (0/0 = -0/0) & @LF) ConsoleWrite("0/0 < -0/0" & @TAB & (0/0 < -0/0) & @LF) Edited August 25 by jchd Fixed typos in +/- normal signaling NANs values. genius257, Trong and Werty 2 1 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)
jchd Posted August 25 Posted August 25 Added more (all?) cases of infinities, indeterminates and clarified NANs (Not A Number) categories. Trong 1 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)
jchd Posted Sunday at 06:57 PM Posted Sunday at 06:57 PM Which part(s) do you feel strange? argumentum 1 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)
Trong Posted Sunday at 08:21 PM Author Posted Sunday at 08:21 PM I have updated the code, are you satisfied? Regards,
jchd Posted Sunday at 08:51 PM Posted Sunday at 08:51 PM I'm always satisfied (I have close to zero use of AutoIt myself)! It's not for me, I did just clear up some dark corners in case you would be interested. 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)
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