Skip to content

EBinary

EchoDevG edited this page Feb 8, 2023 · 2 revisions

EBinary

EBinary is a class which can act as any type of binary that is available. It does this with a string attribute Type which is checked to see what function should be called.

Attributes

Type

Type is a string attribute that is set when the object is instantiated. It can be one of three options:

  • "STANDARD" - A standard binary with no signs
  • "TWOS_COMPLIMENT" - A binary number in two's compliment, where the first bit is negative but has a magnitude as well
  • "SIGN_MAGNITUDE" - A binary number where the first bit is negative, with no magnitude

BinaryNum

BinaryNum holds the number in binary. It can be set with a binary number, or a denary number which is converted to binary.

Length

The Length attribute holds the number of bits in the binary number.

Methods

SetBinaryWithDenary(int denary)

SetBinaryWithDenary does not return anything. It takes an int as a parameter. It sets the BinaryNum attribute to the binary representation of the denary that was inputted, in the style specified by the Type attribute.

GetDenary()

GetDenary returns an int, which is the denary representation of the the binary held in BinaryNum. It takes no parameters. It automatically adjusts for the Type.

Clone this wiki locally