org.vizzini.math
Class BinaryEncoder

java.lang.Object
  extended by org.vizzini.math.BinaryEncoder

public class BinaryEncoder
extends Object

Provides an encoder for binary numbers.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Constructor Summary
BinaryEncoder(double max)
          Construct this object with the given parameter.
BinaryEncoder(double min, double max)
          Construct this object with the given parameters.
BinaryEncoder(double min, double max, double delta)
          Construct this object with the given parameters.
 
Method Summary
static int computeDigits(double range, double delta)
          Compute the number of binary digits required to hold the given range.
 double decode(double[] value)
          Decode the given value as a base-10 number.
 double decode(String value)
          Decode the given value as a base-10 number.
 BitSet encodeAsBitSet(double value)
          Encode the given value as a binary number.
 double[] encodeAsDoubleArray(double value)
          Encode the given value as a binary number.
 int[] encodeAsIntArray(double value)
          Encode the given value as a binary number.
 String encodeAsString(double value)
          Encode the given value as a binary number.
 double getDelta()
           
 int getLength()
           
 double getMax()
           
 double getMin()
           
 double getRange()
           
protected  void setDelta(double delta)
           
protected  void setLength(int length)
           
protected  void setMax(double max)
           
protected  void setMin(double min)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryEncoder

public BinaryEncoder(double max)
Construct this object with the given parameter.

Parameters:
max - Maximum value.
Since:
v0.3

BinaryEncoder

public BinaryEncoder(double min,
                     double max)
Construct this object with the given parameters.

Parameters:
min - Minimum value.
max - Maximum value.
Since:
v0.3

BinaryEncoder

public BinaryEncoder(double min,
                     double max,
                     double delta)
Construct this object with the given parameters.

Parameters:
min - Minimum value.
max - Maximum value.
delta - Delta value, or required precision.
Since:
v0.3
Method Detail

computeDigits

public static int computeDigits(double range,
                                double delta)
Compute the number of binary digits required to hold the given range.

Parameters:
range - Range.
Since:
v0.3

decode

public double decode(double[] value)
Decode the given value as a base-10 number.

Since:
v0.3

decode

public double decode(String value)
Decode the given value as a base-10 number.

Since:
v0.3

encodeAsBitSet

public BitSet encodeAsBitSet(double value)
Encode the given value as a binary number.

Parameters:
value - Value.
Since:
v0.3

encodeAsDoubleArray

public double[] encodeAsDoubleArray(double value)
Encode the given value as a binary number.

Parameters:
value - Value.
Since:
v0.3

encodeAsIntArray

public int[] encodeAsIntArray(double value)
Encode the given value as a binary number.

Parameters:
value - Value.
Since:
v0.3

encodeAsString

public String encodeAsString(double value)
Encode the given value as a binary number.

Parameters:
value - Value.
Since:
v0.3

getDelta

public double getDelta()
Returns:
Return delta.

getLength

public int getLength()
Returns:
Return length.

getMax

public double getMax()
Returns:
Return max.

getMin

public double getMin()
Returns:
Return min.

getRange

public double getRange()

setDelta

protected void setDelta(double delta)
Parameters:
delta - the delta to set

setLength

protected void setLength(int length)
Parameters:
length - the length to set

setMax

protected void setMax(double max)
Parameters:
max - the max to set

setMin

protected void setMin(double min)
Parameters:
min - the min to set


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02