be.ac.ulg.montefiore.run.totem.util
Class FloatingPointArithmetic

java.lang.Object
  extended by be.ac.ulg.montefiore.run.totem.util.FloatingPointArithmetic

public class FloatingPointArithmetic
extends java.lang.Object

Manipulate floating-point (float) numbers.

Creation date: 4 sept. 2006

Author:
Ga�l Monfort (monfort@run.montefiore.ulg.ac.be)

Constructor Summary
FloatingPointArithmetic()
           
 
Method Summary
static java.lang.String getBitString(float value)
          Returns a string representing the bits of a float, in a readable format.
static int getExponent(float value)
          Return the exponent of a float.
static float getMantisse(float value)
          returns the mantisse of a float
static float round(float bigNumber, float smallNumber)
          Round a small number so that it have the same precision of a big number.
If we know x <= bignumber and b1 + b2 + ...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FloatingPointArithmetic

public FloatingPointArithmetic()
Method Detail

getExponent

public static int getExponent(float value)
Return the exponent of a float.

Parameters:
value -
Returns:

getMantisse

public static float getMantisse(float value)
returns the mantisse of a float

Parameters:
value -
Returns:

getBitString

public static java.lang.String getBitString(float value)
Returns a string representing the bits of a float, in a readable format.

Parameters:
value -
Returns:

round

public static float round(float bigNumber,
                          float smallNumber)
Round a small number so that it have the same precision of a big number.
If we know x <= bignumber and b1 + b2 + ... + bn = x then if all bi are rounded relative to the big number, we have x - b1 - b2 - ... - bn = 0.
This is not the case if the numbers are not rounded, due to floating point lack of precision.

Parameters:
bigNumber -
smallNumber -
Returns:


Copyright © 2004-2007 Research Unit in Networking, All Rights Reserved.