net.sf.latexdraw.util
Class LNumber

java.lang.Object
  extended by net.sf.latexdraw.util.LNumber

public final class LNumber
extends java.lang.Object

The class define some useful methods to manage numbers. This file is part of LaTeXDraw.
Copyright(c) 2005-2012 Arnaud BLOUIN

LaTeXDraw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.

LaTeXDraw is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

12/18/06

Version:
3.0
Author:
Arnaud BLOUIN

Field Summary
static LNumber INSTANCE
          The singleton.
static double THRESHOLD
          The threshold used to compare double values.
 
Constructor Summary
private LNumber()
           
 
Method Summary
 boolean equals(double a, double b)
          Compares two double values to know if they are approximatively equal.
 boolean equals(double a, double b, double threshold)
          Compares two double values to know if they are approximately equal.
 double getCutNumber(double value)
          See getCutNumber(double value, double threshold).
 double getCutNumber(double value, double threshold)
          This method allows to set a threshold that if a number is under it, it will be considered as valuing 0; for instance, given the numbers 2E-10 and 0.002 and the threshold 0.00001; then this method will cut the first number and will return 0.
 float getCutNumber(float value)
          See getCutNumber(float value, double threshold).
 float getCutNumber(float value, double threshold)
          This method allows to set a threshold that if a number is under it, it will be considered as valuing 0; for instance, given the numbers 2E-10 and 0.002 and the threshold 0.00001; then this method will cut the first number and will return 0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final LNumber INSTANCE
The singleton.


THRESHOLD

public static final double THRESHOLD
The threshold used to compare double values.

See Also:
Constant Field Values
Constructor Detail

LNumber

private LNumber()
Method Detail

equals

public boolean equals(double a,
                      double b,
                      double threshold)
Compares two double values to know if they are approximately equal.

Parameters:
a - The first double value.
b - The second double value.
threshold - The threshold used to compare the given values.
Returns:
True if both values are approximatively equal using a threshold approximation value.
Since:
3.0

equals

public boolean equals(double a,
                      double b)
Compares two double values to know if they are approximatively equal.

Parameters:
a - The first double value.
b - The second double value.
Returns:
True if both values are approximatively equal using a threshold approximation value.
Since:
3.0

getCutNumber

public float getCutNumber(float value)
See getCutNumber(float value, double threshold). The threshold is by default the constant value THRESHOLD.

Parameters:
value - The value to cut.
Returns:
The cut or the intact number.
Since:
3.0

getCutNumber

public double getCutNumber(double value)
See getCutNumber(double value, double threshold). The threshold is by default the constant value THRESHOLD.

Parameters:
value - The value to cut.
Returns:
The cut or the intact number.
Since:
3.0

getCutNumber

public float getCutNumber(float value,
                          double threshold)
This method allows to set a threshold that if a number is under it, it will be considered as valuing 0; for instance, given the numbers 2E-10 and 0.002 and the threshold 0.00001; then this method will cut the first number and will return 0. The absolute value of the second number is not lesser than the threshold so it will be returned intact.

Parameters:
value - The number to check.
threshold - The minimum threshold of the value.
Returns:
The cut or the intact number.
Since:
1.9

getCutNumber

public double getCutNumber(double value,
                           double threshold)
This method allows to set a threshold that if a number is under it, it will be considered as valuing 0; for instance, given the numbers 2E-10 and 0.002 and the threshold 0.00001; then this method will cut the first number and will return 0. The absolute value of the second number is not lesser than the threshold so it will be returned intact.

Parameters:
value - The number to check.
threshold - The minimum threshold of the value.
Returns:
The cut or the intact number.
Since:
1.9