org.fixbin.light
Class FixBinNoTrig

java.lang.Object
  extended byorg.fixbin.light.FixBinNoTrig

public class FixBinNoTrig
extends java.lang.Object

FixBin the light version of the FixBin library this class can be used in 2 ways: either the static methods are used or alternatively it can be used to instantiate objects that handle the values (much like the StringBuffer class). Example 1: FixBin myVal = new FixBin("1.234"); myVal.mul(3); System.out.println("Result: " + myVal); Example 2: long myVal = FixBin-toFixBin("1.234"); long val3 = FixBin.toFixBin("3"); myVal = FixBin.mul(myVal, val3); System.out.println("Result: " + FixBin.toString(myVal));


Field Summary
protected static int commaBitPos
           
protected static long commaBitVal
           
static long E
           
static long PI
           
static long PI2
           
 
Constructor Summary
protected FixBinNoTrig()
          create a new instance of FixBin with value 0.0
 
Method Summary
static long abs(long val)
          Returns the absolute value of a fixbin-encoded val
static long add(long x, long y)
          adds two fixbin-values
static int compareTo(long x, long y)
          Compares two (fixbin-encoded) values and returns 1 if x > y, -1 if x < y, 0 if x == y
static long div(long val1, long val2)
          Divide two fixbin-encoded values
static long exp(long val)
          Calculates e^val val should be fixbin encoded
static java.lang.String format(long fixVal, int decimals)
          formats a fixbin-coded value to a String with a given number of figures after the decimal point
static int intValue(long val)
          Returns the integer-value of a given fixbin-encoded val
static long ln(long val)
          Calculates the natural log of the given fixbin-encoded val
protected static long lngt1(long val)
          Calculates the natural log for values > 1
protected static long lnlt1(long val)
          Calculates the natural log for values < 1
static long longValue(long val)
          Returns the long-value of a given fixbin-encoded val
static long mul(long val1, long val2)
          Multiply two fixbin encoded values
static long pow(long x, int howmany)
          Calculates the power of the first parameter by the second.
static long pow(long bas, long exp)
          Calculates the power of the first parameter by the second.
static long sqr(long x)
          Calculate the square of the given fixbin-encoded value
static long sqrt(long val)
          Calculates the square root of the given fixbin-encoded value
static long sqrt(long val, int nth)
          Calculates the nth root of the given value (val). val should be fixbin-encoded, nth is just an integer value
static long sub(long x, long y)
          Substract two fixbin-coded values
static long toFixBin(int val)
          Transform an integer to a FixBin coded long
static long toFixBin(long val)
          Transform a long value to a FixBin coded long
static long toFixBin(java.lang.String init)
          Transform a String into a fixbin-coded LONG
static java.lang.String toString(long fixVal)
          returns the value of the fixbin-coded value as a String
protected static long xbyndivnfact(long x, int n)
          This is a helper method required by other exponential methods it calculates x ^ n / n!
protected static long xmmbyndivnxppbynx2(long x, int n)
          calculates an intermediate value for ln
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commaBitPos

protected static final int commaBitPos
See Also:
Constant Field Values

commaBitVal

protected static final long commaBitVal
See Also:
Constant Field Values

PI

public static long PI

E

public static long E

PI2

public static long PI2
Constructor Detail

FixBinNoTrig

protected FixBinNoTrig()
create a new instance of FixBin with value 0.0

Method Detail

toFixBin

public static long toFixBin(java.lang.String init)
Transform a String into a fixbin-coded LONG

Parameters:
init - (String)
Returns:
long

toFixBin

public static long toFixBin(int val)
Transform an integer to a FixBin coded long

Parameters:
val - (int)
Returns:
long

toFixBin

public static long toFixBin(long val)
Transform a long value to a FixBin coded long

Parameters:
val - (long)
Returns:
long

format

public static java.lang.String format(long fixVal,
                                      int decimals)
formats a fixbin-coded value to a String with a given number of figures after the decimal point

Parameters:
fixVal - (long)
decimals - (int)
Returns:
String

toString

public static java.lang.String toString(long fixVal)
returns the value of the fixbin-coded value as a String

Parameters:
fixVal - (long)
Returns:
String

add

public static long add(long x,
                       long y)
adds two fixbin-values

Parameters:
x - (long)
y - (long)
Returns:
x+y (long)

sub

public static long sub(long x,
                       long y)
Substract two fixbin-coded values

Parameters:
x - (long)
y - (long)
Returns:
x-y (long)

mul

public static long mul(long val1,
                       long val2)
Multiply two fixbin encoded values

Parameters:
val1 - (long)
val2 - (long)
Returns:
val1 * val2 (long)

div

public static long div(long val1,
                       long val2)
Divide two fixbin-encoded values

Parameters:
val1 - (long)
val2 - (long)
Returns:
val1 / val2 (long)

sqr

public static long sqr(long x)
Calculate the square of the given fixbin-encoded value

Parameters:
x - (long)
Returns:
x^2 (long)

pow

public static long pow(long x,
                       int howmany)
Calculates the power of the first parameter by the second. All values except howmany should of course be fixbin-encoded

Parameters:
x - (long)
howmany - (int)
Returns:
x^howmany

pow

public static long pow(long bas,
                       long exp)
                throws java.lang.Exception
Calculates the power of the first parameter by the second. All values should of course be fixbin-encoded

Returns:
x^y (long)
Throws:
java.lang.Exception

sqrt

public static long sqrt(long val)
                 throws java.lang.Exception
Calculates the square root of the given fixbin-encoded value

Parameters:
val - (long)
Returns:
sqrt(val) (long)
Throws:
java.lang.Exception

sqrt

public static long sqrt(long val,
                        int nth)
                 throws java.lang.Exception
Calculates the nth root of the given value (val). val should be fixbin-encoded, nth is just an integer value

Parameters:
val - (long)
nth - (int)
Returns:
val ^ (1/nth) (long)
Throws:
java.lang.Exception

xbyndivnfact

protected static long xbyndivnfact(long x,
                                   int n)
This is a helper method required by other exponential methods it calculates x ^ n / n!

Parameters:
x - (long)
n - (int)
Returns:
long

exp

public static long exp(long val)
                throws java.lang.Exception
Calculates e^val val should be fixbin encoded

Parameters:
val - (long)
Returns:
e^val (long)
Throws:
java.lang.Exception

xmmbyndivnxppbynx2

protected static long xmmbyndivnxppbynx2(long x,
                                         int n)
calculates an intermediate value for ln

Parameters:
x - (long)
n - (int)
Returns:
long

lngt1

protected static long lngt1(long val)
                     throws java.lang.Exception
Calculates the natural log for values > 1

Parameters:
val - (long)
Returns:
ln(val) (long)
Throws:
java.lang.Exception

lnlt1

protected static long lnlt1(long val)
                     throws java.lang.Exception
Calculates the natural log for values < 1

Parameters:
val - (long)
Returns:
ln(this) (long)
Throws:
java.lang.Exception

ln

public static long ln(long val)
               throws java.lang.Exception
Calculates the natural log of the given fixbin-encoded val

Parameters:
val - (long)
Returns:
ln(val) (long)
Throws:
java.lang.Exception

intValue

public static int intValue(long val)
Returns the integer-value of a given fixbin-encoded val

Parameters:
val - (long)
Returns:
(int)

longValue

public static long longValue(long val)
Returns the long-value of a given fixbin-encoded val

Parameters:
val - (long)
Returns:
(long)

compareTo

public static int compareTo(long x,
                            long y)
Compares two (fixbin-encoded) values and returns 1 if x > y, -1 if x < y, 0 if x == y

Parameters:
x - (long)
y - (long)
Returns:
int

abs

public static long abs(long val)
Returns the absolute value of a fixbin-encoded val

Returns:
abs(val)