czardas Posted August 14, 2012 Share Posted August 14, 2012 (edited) Even though it returns a result, the following code appears to be meaningless. The maximum possible shift is -31 to 31 (not -99999). Note: passing different out of bounds values for the shift parameter returns different results. I was wondering what was happening. $a = BitShift(1, -99999) MsgBox(0, "Meaningless", $a) Edited August 14, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
trancexx Posted August 14, 2012 Share Posted August 14, 2012 What is the question (that help file doesn't answer)? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
czardas Posted August 14, 2012 Author Share Posted August 14, 2012 (edited) The help file explains things clearly enough. Since it states that the function only works with numbers that fit in a 32 bit signed integer, I pressumed that shift values greater than 31 would produce out of bounds results. I really wanted to make sure I wasn't missing some important information (although I think I've got my head around it now) - in which case perhaps the Help file could mention something more about the shift parameter. Edited August 14, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
James Posted August 14, 2012 Share Posted August 14, 2012 So you're saying the help file is wrong? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
czardas Posted August 14, 2012 Author Share Posted August 14, 2012 (edited) So you're saying the help file is wrong?I'm waiting for additional feedback before saying something like that. I don't really think the help file is wrong, just that some details appear undocumented.EditMeh, the function seems to just simply be broken. It's not, it just seems to be. Edited August 14, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted August 14, 2012 Author Share Posted August 14, 2012 (edited) To clarify my intentions: I am currently creating a small set of selected functions where all error checks are handled internally and do not need to be checked by the user. Each function will first check if an error has occured within a previously nested function. This is why I ask such questions (since I don't want to get this wrong), and here's what I have come up with for BitShift. Global $_KickBack_ = 0 ; Count for nested function errors $ret = _BitShift(Hex(15), 1) ; This nesting does not work with the native BitShift function. MsgBox(0, @extended, $ret) Func _BitShift($nValue, $nShift) If $_KickBack_ > 0 Then Return SetError(1, _HardError(), "NaN") If Not IsNumber($nValue) Then $nValue = Dec($nValue) If @error Then Return SetError(2, _HardError(), "NaN") If Not IsNumber($nShift) Then $nShift = Dec($nShift) If @error Then Return SetError(3, _HardError(), "NaN") If $nValue < -2147483648 Or $nValue >= 2147483648 Then Return SetError(4, _HardError(), "NaN") Return BitShift($nValue, $nShift) ; No native, or internal, error checks exist EndFunc ;==>_BitShift Func _HardError() $_KickBack_ += 1 Return $_KickBack_ EndFunc Edited August 14, 2012 by czardas operator64 ArrayWorkshop 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