Skip to content

AboutBitwiseOperations - Error in description? #466

Description

@DEberhardt

Describe "Koan Bug, Issue, or Help Request"

AboutBitwiseOperations

Context "The Problematic Assertions"

The following two statements seem to contradict themselves (it is late here and I am studying, so I will revisit this in the morning again, but I think we have an error in description for LEAST/MOST:

        It 'A byte is made up of 8 bits' {
            <#
                Each bit can be set to either 0 or and each has a value based
                on its position.

                The most significant bit, the largest value, is first. The least
                significant bit, the smallest value, is last.

                    Bit position      Value
                    ------------      -----
                               1        128
                               2         64
                               3         32
                               4         16
                               5          8
                               6          4
                               7          2
                               8          1

                This order is known as Big Endian.
            #>

            '00000001' | ConvertFrom-Binary | Should -Be 1      # Least significant
            '00000010' | ConvertFrom-Binary | Should -Be 2
            '00000100' | ConvertFrom-Binary | Should -Be 4
            '00001000' | ConvertFrom-Binary | Should -Be 8
            '00010000' | ConvertFrom-Binary | Should -Be 16
            '00100000' | ConvertFrom-Binary | Should -Be 32
            '01000000' | ConvertFrom-Binary | Should -Be 64
            '10000000' | ConvertFrom-Binary | Should -Be 128    # Most significant
        }

and

        It 'a binary string can be used to represent different numeric values' {
            # The number it represents can depend on the numeric type used.

            $BinaryValue = '11100001'

            $BinaryValue | ConvertFrom-Binary -To Byte | Should -Be 225
            $BinaryValue | ConvertFrom-Binary -To SByte | Should -Be -31

            <#
                As the signing bit is always the least significant, converting the 8 bit
                binary value above to a larger type, such as, Int32 will create a positive value.
            #>

            $BinaryValue | ConvertFrom-Binary -To Int32 | Should -Be 225
        }

I think this should read As the signing bit is always the most significant...

Context "Your Attempts"

an attempt at understanding late at night.

Context "Additional Information"

the moon illuminates a path

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions