CPU Simulator
    Preparing search index...

    This class represents a byte sized binary value.

    Erik Burmester erik.burmester@nextbeam.net

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    MAX_NEGATIVE_NUMBER_DEC: number = -128
    MAX_POSITIVE_NUMBER_DEC: number = 127
    NUMBER_OF_BITS_DEC: number = 8
    _value: Bit[]

    An array of bits, representing a binary value.

    Accessors

    Methods

    • This method creates an instance from the given number. Throws an error, if the given number is not an integer. It uses the second parameter as an indicator whether to convert the integer value into a signed or unsigned binary value. This parameter is needed, because not all values in the context of a CPU can be treated as signed binary values. For example a memory address can never be a negative value. Therefore, such a binary value should always be considered unsigned. Depending on the second parameter, the range of allowed values is slightly different. This method throws an error, if the value to be converted is too large or too small.

      Parameters

      • integer: number

        The number to initialize the new instances value with.

      Returns Byte

      A new instance.

    • For comparison, both binary values are converted to strings. Conversion presarves the order of items, which is important for the comparison.

      Parameters

      • byte: Byte

        The binary value to compare to.

      Returns boolean

      True, when both binary values are identical, false otherwise.