com.monkeycoder.monkeynes.base
Class MathHelper

java.lang.Object
  |
  +--com.monkeycoder.monkeynes.base.MathHelper

public class MathHelper
extends Object

This class provdes several math related convenience constructs.

Originally part of the MonkeyNes project.

Author:
David Stephens

Field Summary
static int[] bitMask
          This array allows access to individual bits.
static int[] byteMask
          This array allows access to individual bytes.
static int[] nibbleMask
          This array allows access to individual nibbles.
 
Method Summary
static String getBinaryString8(int inInt)
          Builds a 0 padded 8-bit binary string from an integer.
static String getHexString(int inInt)
          Builds a 0 padded 32-bit hexidecimal string from an integer.
static String getHexString16(int inInt)
          Builds a 0 padded 16-bit hexidecimal string from an integer.
static String getHexString8(int inInt)
          Builds a 0 padded 8-bit hexidecimal string from an integer.
static int getWrappedAddress(int addr)
          Forces an address to stay within the 64k range by wrapping it.
static int getWrappedByte(int addr)
          Forces a byte to stay within the 0-255 range by wrapping it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bitMask

public static final int[] bitMask
This array allows access to individual bits.


nibbleMask

public static final int[] nibbleMask
This array allows access to individual nibbles.


byteMask

public static final int[] byteMask
This array allows access to individual bytes.

Method Detail

getWrappedAddress

public static int getWrappedAddress(int addr)
Forces an address to stay within the 64k range by wrapping it.

Parameters:
addr - The address to access.
Returns:
The wrapped address.

getWrappedByte

public static int getWrappedByte(int addr)
Forces a byte to stay within the 0-255 range by wrapping it.

Parameters:
addr - The address to access.
Returns:
The wrapped address.

getHexString

public static String getHexString(int inInt)
Builds a 0 padded 32-bit hexidecimal string from an integer.

Parameters:
inInt - The number to convert into a hexidecimal string.
Returns:
The converted string.

getHexString8

public static String getHexString8(int inInt)
Builds a 0 padded 8-bit hexidecimal string from an integer.

Parameters:
inInt - The number to convert into a hexidecimal string.
Returns:
The converted string.

getHexString16

public static String getHexString16(int inInt)
Builds a 0 padded 16-bit hexidecimal string from an integer.

Parameters:
inInt - The number to convert into a hexidecimal string.
Returns:
The converted string.

getBinaryString8

public static String getBinaryString8(int inInt)
Builds a 0 padded 8-bit binary string from an integer.

Parameters:
inInt - The number to convert into a binary string.
Returns:
The converted string.