cds.util
Class FloatPrec

java.lang.Object
  extended bycds.util.Nodata
      extended bycds.util.FloatPrec
All Implemented Interfaces:
java.io.Serializable

public class FloatPrec
extends Nodata

Float number with precision

Version:
1.0 30 oct 2002
, 1.1 Sep 2003 MW, 1.2 Jan 2004 (BB) ajout de la methode equals.
Author:
Sylvaine Jaehn (Stage UTBM), Marc Wenger/CDS
See Also:
Serialized Form

Field Summary
private  float nb
           
private static FloatPrec NODATA_FP
           
private static java.lang.String NODATA_STR
           
private  short prec
           
 
Fields inherited from class cds.util.Nodata
NODATA, NODATA_DBL, NODATA_FLT, NODATA_SHT
 
Constructor Summary
FloatPrec()
          Empty constructor.
FloatPrec(FloatPrec fp)
          Copy constructor
FloatPrec(float nb, short prec)
          Constructor with parameters
FloatPrec(java.lang.String nb)
          Constructor initializing a FloatPrec number with a string
 
Method Summary
private  short calculatePrec(java.lang.String nb)
          Computes the precision (number of decimal digits)
 boolean equals(java.lang.Object o)
          MOD-BB 21-01-04 Ajout de cette methode.
 float getFloat()
          Returns the floating point value
 short getPrec()
          Returns the precision value
 void set(FloatPrec fp)
          Sets the FloatPrec object from another one
 void set(java.lang.String nb)
          Sets the FloatPrec number value from a string
 void setPrec(short prec)
          Sets the precision
 java.lang.String toString()
          Display the number in a string
 java.lang.String toString(boolean signed)
          Display the FloatPrec number
 java.lang.String toString(short precision, boolean signed)
          Display the FloatPrec number with a defined precision.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NODATA_FP

private static final FloatPrec NODATA_FP

NODATA_STR

private static final java.lang.String NODATA_STR

nb

private float nb

prec

private short prec
Constructor Detail

FloatPrec

public FloatPrec()
Empty constructor. Creates a number with no data


FloatPrec

public FloatPrec(java.lang.String nb)
Constructor initializing a FloatPrec number with a string

Parameters:
nb - decimal number in a string

FloatPrec

public FloatPrec(FloatPrec fp)
Copy constructor

Parameters:
fp - FloatPrec number

FloatPrec

public FloatPrec(float nb,
                 short prec)
Constructor with parameters

Parameters:
nb - floating point number (value)
prec - precision (number of decimal digits)
Method Detail

set

public void set(FloatPrec fp)
Sets the FloatPrec object from another one

Parameters:
fp - FloatPrec object to copy

set

public void set(java.lang.String nb)
Sets the FloatPrec number value from a string

Parameters:
nb - decimal number as a string

setPrec

public void setPrec(short prec)
Sets the precision

Parameters:
prec - precision (O: no dec, 1: 1 dec, ...)

calculatePrec

private short calculatePrec(java.lang.String nb)
Computes the precision (number of decimal digits)

Parameters:
nb - number (string) from which the precision should be computed
Returns:
precision value (actual number of decial digits)

getFloat

public float getFloat()
Returns the floating point value

Returns:
The FloatPrec value as a float

getPrec

public short getPrec()
Returns the precision value

Returns:
number of decimal digits of the FloatPrec number

toString

public java.lang.String toString()
Display the number in a string

Returns:
the string with the decimal number displayed with the correct number of decimal digits

toString

public java.lang.String toString(boolean signed)
Display the FloatPrec number

Parameters:
signed - true if the sign should be displayed. false otherwise
Returns:
the string with the displayed number

toString

public java.lang.String toString(short precision,
                                 boolean signed)
Display the FloatPrec number with a defined precision. This method allows to force a precision

Parameters:
precision - defined precision
signed - true if the sign should be displayed
Returns:
the string containing the edited FloatPrec number

equals

public boolean equals(java.lang.Object o)
MOD-BB 21-01-04 Ajout de cette methode. Comparaison de FloatPrec.

Parameters:
o - Objet a comparer.
Returns:
Vrai si o est identique a this, faux sinon.