Page 1 of 1
Windows PowerShell 101 DVD Question
Posted: Fri Mar 28, 2008 6:43 am
by jsclmedave
Question is -
Type the comparison that will allow PowerShell to determine if the fourth bit is "turned on" in the value 192.
Answer is -
129 -band 8
8 -band 129
I am at a loss here... If this is indeed correct can someone please explain?
Windows PowerShell 101 DVD Question
Posted: Fri Mar 28, 2008 6:43 am
by jsclmedave
Question is -
Type the comparison that will allow PowerShell to determine if the fourth bit is "turned on" in the value 192.
Answer is -
129 -band 8
8 -band 129
I am at a loss here... If this is indeed correct can someone please explain?
Windows PowerShell 101 DVD Question
Posted: Fri Mar 28, 2008 8:12 am
by jvierra
Bit 4 has a value of 8 when set.
2 ** (4-1) or 2 two the third power which is 2 * 2 * 2 or 8.
if bit and 8 matces bit by bit with 129 it will be true.
129 = 10000001 ( 128 + 1) or ( bit 8 + bit 1)
8 = 00001000
Does it match at the bit position.
Try 137 -band 8 it will tell you True.
false = 0
true <> 0
Try the following
[bool]0
[bool]1
[bool]-1
[bool](129 -band 8)
[bool](137 -band 8)
[bool](8 -band 8)
Now are you a believer?
Windows PowerShell 101 DVD Question
Posted: Fri Apr 04, 2008 7:17 am
by jsclmedave
Where does the 129 come in? They are all false which I get. The 4th BIT which is 8 in not true.
PS Z:> [bool]0FalsePS Z:> [bool]1TruePS Z:> [bool]-1TruePS Z:> [bool](129 -band 8)FalsePS Z:> [bool](137 -band 8)TruePS Z:> [bool](8 -band 8)TruePS Z:> [bool](8 -band 129)FalsePS Z:> [bool](8 -band 192)FalsePS Z:> [bool](192 -band 8)FalsePS Z:>
So shouldnt the answer to this question be - ?
192 -band 8
8 -band 192
It looks like a typo... If not I am completely lost as to where the 129 came from...
Windows PowerShell 101 DVD Question
Posted: Fri Apr 04, 2008 7:35 am
by donj
Sorry, "192." Misread the question. But yes, the correct answer should be
8 -band 192
or
192 -band 8
If it isn't accepting that, then there may be a typo in the quiz module. It's also possible there's an extra or missing space; the quiz module is unfortunately extremely picky about that kind of thing.
Windows PowerShell 101 DVD Question
Posted: Sun Apr 06, 2008 11:20 pm
by jsclmedave
Thank you all for the clarification and detailed information! Don - The module states the correct answer is - 129 -band 88 -band 129
So yes, I believe it