jmce - 1_02

jmce.sim.cpu
Class Binary

java.lang.Object
  extended by jmce.sim.cpu.Binary

public class Binary
extends java.lang.Object

Sample class to deal with binary number.

This class make easy set / reset single bit in one integer number.

Since:
1.00
Version:
1.00
Author:
Mario Viara

Constructor Summary
Binary()
          Default constructor.
Binary(int n)
          Constructor with specific number
 
Method Summary
 boolean getBit(int b)
          Return the specified bit.
 int getValue()
          Return the current value.
 void setBit(int b, boolean v)
          Set a value for specific bit.
 void setValue(int n)
          Set the current value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Binary

public Binary()
Default constructor.


Binary

public Binary(int n)
Constructor with specific number

Method Detail

setValue

public void setValue(int n)
Set the current value.


getValue

public int getValue()
Return the current value.


setBit

public void setBit(int b,
                   boolean v)
Set a value for specific bit.

Parameters:
b - - Bit number 0 .. 31
v - - Bit value (true = 1, false = 0)

getBit

public boolean getBit(int b)
Return the specified bit.

Parameters:
b - - Number of bit 0 .. n
Returns:
true if the specified bit is set.

jmce - 1_02