"AboutBitWiseOperations" a few things to look at #349
Labels
Category-Koans
Invoking the Great Doubt
Issue-Bug 🐛
Something's wrong!
Issue-Discussion
Let's talk about it!
Projects
Issue 1
Original Code at Line 52
52 if ($To -ne 'String') {
Modified Code at Line 52
52 if ($To -ne 'ASCIIString') {
Conversions as specified in the rest of the script have lots of problems
Issue 2
Original Code starting a line 204
204 $Value = '00000011' | ConvertFrom-Binary
205 $Result = '________' | ConvertFrom-Binary
206
207 -bnot $Value | Should -Be $Result
Modified Code at line 205
205 $Result = ' ________ ' | ConvertFrom-Binary -To ' ________ '
Since by default $Value is a signed value the result of “bnot” makes it negative, to deal with this you have to select the correct conversion type to work with the $Result value.
Since you deal with signed values later in the koan, this may be a bit early to be discovering this scenario.
Issue 3
Original Code at line 351
351 $Value.Sum | Should -Be 1652126821
Modified Code at line 351
351 $Value.Sum | Should -Be 1075843080
No sure if this was just bad math on someone's part or not.
Issue 4
Original Code at line 394
394 '1000000' | ConvertFrom-Binary -To SByte
Modified Code at line 394
394 '10000000' | ConvertFrom-Binary -To SByte
You are missing a “0”.
Issue 5
Original Code at line 463 - 465
463 $Date = [DateTime]::FromFileTime(($BinaryValue | ConvertFrom-Binary -To Int64))
465 $Date | Should -Be '01 January 1601 00:02:45'
Modified Code at line 463 - 467
463 $Date = [DateTime]::FromFileTime(($BinaryValue | ConvertFrom-Binary -To Int32))
465 $Date.DateTime | Should -Be 'Sunday, 31 December, 1600 6:02:45 PM'
466 $Date.Ticks | Should -Be 504911017652126821
467 $Date | Should -Be ([DateTime]'1600-12-31T18:02:45.2126821-06:00')
There are a couple of issues here
So there are a couple of different ways to play with this
a. The string representation: $Date:DateTime
b. Maybe look at the number of ticks: $Date.Ticks
I may have completely missed the boat here, if so let me know.
Issue 6
Original Code at line 510
510 [BitConverter]::ToInt32($Bytes, 0) | Should -Be 1702132066
Modified Code to replace line 510
If([BitConverter]::IsLittleEndian)
{
[BitConverter]::ToInt32($Bytes, 0) | Should -Be 1652126821
}
else
{
[BitConverter]::ToInt32($Bytes, 0) | Should -Be 1702132066
}
Because surprise, surprise, my system operates in Little Endian, so you have to check before you do the Should -Be Test, and others may experience a similar problem.
The text was updated successfully, but these errors were encountered: