GargoyleGargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Okay I am not the best person at math, I never got past algerbra, so I am requesting what is most likely a simple question.
I have an array with elements that contain 0 or -1, and I want to see if all elements are = -1, and I thought that the best way to do this would be a bitwise operation but not sure which one would be correct
Code:
$array = 0,0,0,-1,0,-1; example of what the array would contain. ;Option 1 For $ = 0 to 5 $2 = $2 | $array[$] Next
;Option 2 For $ = 0 to 5 $2 = $2 ^ $array[$] Next
;Option 3
For $ = 0 to 5 $2 = $2 ~ $array[$] Next
I just am not sure which operator I would use.
Thanks
_________________________
Today is the tomorrow you worried about yesterday.
GargoyleGargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
In the end I need to know if all the elements are -1 and be able to set a variable to say all = -1 (true) or all elements do not = - 1 (false)
so to continue the examples above
Code:
$array = 0,0,0,-1,0,-1; example of what the array would contain. ;Option 1 For $ = 0 to 5 $2 = $2 | $array[$] Next If $2 = -1 $Flag = "True" Else $Flag = "False" EndIf ;Option 2 For $ = 0 to 5 $2 = $2 ^ $array[$] Next If $2 = -1 $Flag = "True" Else $Flag = "False" EndIf ;Option 3
For $ = 0 to 5 $2 = $2 ~ $array[$] Next If $2 = -1 $Flag = "True" Else $Flag = "False" EndIf
WittoWitto
MM club member
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Code:
Break On $array = 0,0,0,-1,0,-1 $flag = 'true' For $n = 0 to Ubound($array) If $array[$n] = -1 ? 'Element ' + $n ' is -1' Else $flag = "false" $n = Ubound($array) EndIf Next ? "All elements were -1 = " + $flag