Jump to content

Search the Community

Showing results for tags 'negative'.

  • 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

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

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 2 results

  1. Hi, I wondered why negative integers I wrote into registry (e.g. negative x-coordinates of a gui if using two monitors and the right one is the main one) wouldn't return right when reading. Now I know: it is saved as an unsigned integer (without algebraic sign). So here is a snippet that is changing unsigned to signed integer: Global Const $g_sRegKey = "HKEY_CURRENT_USER\Software\" & @ScriptName ; path to registry RegWrite($g_sRegKey, "Value", "REG_DWORD", -2147483647) ; write some negative integer into registry; -2147483647 highest possible negative integer , 2147483648 highest possible positive integer if talking of 32bit Local $sValue = RegRead($g_sRegKey, "Value") ; read out registry ConsoleWrite("Value: " & $sValue & @CRLF) ; show real value in console Local $sResult = _SignedInteger($sValue) ; change to signed value ConsoleWrite("Result: " & $sResult & @CRLF) ; and show it in console Func _SignedInteger($iUnsignedInteger) Local $iSignedInteger If $iUnsignedInteger > (2^31) Then ; then it means a negative integer $iSignedInteger = $iUnsignedInteger - (2^32) Else $iSignedInteger = $iUnsignedInteger EndIf Return $iSignedInteger EndFunc It took me some time to find out the problem and so I hope I can help somebody with this. Regards, Conrad
  2. hi everyone! I need some help with my rpn calculator. I first translated it from vbscript to autoitscript and that's when i stumbled on problem one: (46) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $Stack[ubound($Stack)] = $Item ^ ERROR After that (and i know this from testing it as a vbscript) it can't work with negative numbers: "1 - - 2" to Reverse Polish notation = "1 - 2 -" gives me the build in error... Can you guy's help me with my code pleas? Func Print($what,$er = 0) $t = '' if $err <> 0 then $t = 'ERROR!' MsgBox($er,$st,$what) EndFunc Func RPN($Tokenarray) Local $Stack = [] Local $Result Local $Operator_B Local $Operator_A For $Token = 0 To Ubound($Tokenarray) If Isoperator($Tokenarray[$Token]) Then $Operator_B = Pop($Stack) $Operator_A = Pop($Stack) If $Operator_A = "" Then Print("The user has not input sufficient values in the expression.",16) exit EndIf Switch $Tokenarray[$Token] Case "+" $Result = Number($Operator_A,3) + Number($Operator_B,3) Case "-" $Result = Number($Operator_A,3) - Number($Operator_B,3) Case "*" $Result = Number($Operator_A,3) * Number($Operator_B,3) Case "/" $Result = Number($Operator_A,3) / Number($Operator_B,3) Case "^" $Result = Number($Operator_A,3) ^ Number($Operator_B,3) EndSwitch Push($Result,$Stack) Else Push($Tokenarray[$Token],$Stack) EndIf Next If Ubound($Stack) > 1 Then Print("The user input has too many values.",16) Exit EndIf Return pop($Stack) EndFunc Func Push($Item, Byref $Stack) If Ubound($Stack) > -1 Then Redim $Stack[Ubound($Stack) + 1] $Stack[Ubound($Stack)] = $Item Else Local $Stack = [$Item] EndIf EndFunc Func Pop($Stack) $pop = "" If Ubound($Stack) > -1 Then $Pop = $Stack[Ubound($Stack)] Redim $Stack[Ubound($Stack) - 1] EndIf Return $pop EndFunc Func Peek($Stack) $peek = "" If Ubound($Stack) > -1 Then $Peek = $Stack(Ubound($Stack)) EndIf Return $peek EndFunc Func Isoperator($Operator) Return StringInstr("+-*/^&<=>", $Operator) <> 0 And StringLen($Operator) = 1 EndFunc Func Precedence($Operator) If Isoperator($Operator) Then Switch $Operator case "^" Return 4 case "*","/" Return 3 case "+","-" Return 2 case "&" Return 1 case "<","=",">" Return 0 EndSwitch EndIf EndFunc ;################################################################################################## ; (4 - -5) = (4|-|-|5) = (4|-|5|-) ; input tokens rpn Global $calculate_this = ["4","-","5","-"] Print(rpn($calculate_this)) thanks in advance , TheAutomator
×
×
  • Create New...