edu.nrao.sss.math
Class MathUtil

java.lang.Object
  extended by edu.nrao.sss.math.MathUtil

public class MathUtil
extends Object

A utility class for mathematical concepts.

Version Info:

$Revision: 1472 $
$Date: 2008-08-06 09:43:05 -0600 (Wed, 06 Aug 2008) $
$Author: dharland $ (last person to modify)

Since:
2008-02-26
Author:
David M. Harland

Field Summary
static MathContext HALF_UP_50
          Deprecated. Use MC_FINAL_CALC or MC_INTERM_CALCS Precision of 50, rounding mode of half-up.
static MathContext MC_FINAL_CALC
          A math context to use when storing object properties as BigDecimals.
static MathContext MC_INTERM_CALCS
          A math context to use on intermediate calculations that are stepping stones to a final value.
static BigDecimal NEGATIVE_INFINITY
          A BigDecimal whose value is negative and whose doubleValue() is infinite according to the Double class.
static BigDecimal POSITIVE_INFINITY
          A BigDecimal whose value is positive and whose doubleValue() is infinite according to the Double class.
 
Constructor Summary
MathUtil()
           
 
Method Summary
static boolean doubleValueIsInfinite(BigDecimal number)
          Returns true if number.doubleValue() is determined to be infinite by the Double class.
static BigDecimal getInfiniteValue(int signum)
          Returns a BigDecimal whose double value is infinite, according to the Double class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HALF_UP_50

@Deprecated
public static final MathContext HALF_UP_50
Deprecated. Use MC_FINAL_CALC or MC_INTERM_CALCS Precision of 50, rounding mode of half-up.

MC_FINAL_CALC

public static final MathContext MC_FINAL_CALC
A math context to use when storing object properties as BigDecimals. This is a very high precision context, but not as high as that of MC_INTERM_CALCS.


MC_INTERM_CALCS

public static final MathContext MC_INTERM_CALCS
A math context to use on intermediate calculations that are stepping stones to a final value. The final calculation should use the MC_FINAL_CALC context, which has a slightly lower precision.


POSITIVE_INFINITY

public static final BigDecimal POSITIVE_INFINITY
A BigDecimal whose value is positive and whose doubleValue() is infinite according to the Double class.

It is important to note that this value is not infinite in the eyes of the BigDecimal class. The BigDecimal class has no concept of infinity. It is also important to note that this value may not be the smallest positive value whose doubleValue() is infinite. This value is convenient for clients who need to approximate Double.POSITIVE_INFINITY in the form of a BigDecimal.

If you want to test a BigDecimal for infinity, do not compare to this value. Instead, use doubleValueIsInfinite(BigDecimal).


NEGATIVE_INFINITY

public static final BigDecimal NEGATIVE_INFINITY
A BigDecimal whose value is negative and whose doubleValue() is infinite according to the Double class.

It is important to note that this value is not infinite in the eyes of the BigDecimal class. The BigDecimal class has no concept of infinity. It is also important to note that this value may not be the largest negative value whose doubleValue() is infinite. This value is convenient for clients who need to approximate Double.NEGATIVE_INFINITY in the form of a BigDecimal.

If you want to test a BigDecimal for infinity, do not compare to this value. Instead, use doubleValueIsInfinite(BigDecimal).

Constructor Detail

MathUtil

public MathUtil()
Method Detail

doubleValueIsInfinite

public static boolean doubleValueIsInfinite(BigDecimal number)
Returns true if number.doubleValue() is determined to be infinite by the Double class.

Parameters:
number - the number to be tested for infinite value.
Returns:
true if number is infinite.

getInfiniteValue

public static BigDecimal getInfiniteValue(int signum)
Returns a BigDecimal whose double value is infinite, according to the Double class.

Parameters:
signum - a positive value will result in a positive return value, and a negative value will result in a negative return value. A value of zero will result in a runtime exception.
Returns:
a positive or negative infinite value.


Copyright © 2009. All Rights Reserved.