com.ibm.eou.decimal
Class ArithmeticConditions

java.lang.Object
  |
  +--com.ibm.eou.decimal.ArithmeticConditions

public class ArithmeticConditions
extends java.lang.Object

This class provides a set of conditions that can arise during numeric conversions and arithmetic operations.

Author:
Dave Clark, IBM Ease of Use

Constructor Summary
ArithmeticConditions()
          Create a set of arithmetic conditions.
 
Method Summary
 boolean equals(java.lang.Object other)
          Return true if the conditions all match.
 int hashCode()
          Return a hash code which will be equal for objects that compare equal, and will preferably be different for objects that compare unequal.
 boolean isClamped()
          Return true if the clamped condition is set.
 boolean isConversionSyntax()
          Return true if the conversion syntax condition is set.
 boolean isDivisionByZero()
          Return true if the division by zero condition is set.
 boolean isDivisionImpossible()
          Return true if the division impossible condition is set.
 boolean isDivisionUndefined()
          Return true if the division undefined condition is set.
 boolean isInexact()
          Return true if the inexact condition is set.
 boolean isInsufficientStorage()
          Return true if the insufficient storage condition is set.
 boolean isInvalidContext()
          Return true if the invalid context condition is set.
 boolean isInvalidOperation()
          Return true if the invalid operation condition is set.
 boolean isLostDigits()
          Return true if the lost digits condition is set.
 boolean isOverflow()
          Return true if the overflow condition is set.
 boolean isRounded()
          Return true if the rounded condition is set.
 boolean isSubnormal()
          Return true if the subnormal condition is set.
 boolean isUnderflow()
          Return true if the underflow condition is set.
 void resetAll()
          Clear all the conditions.
 void setAll(ArithmeticConditions conditions)
          Set all the conditions which are set in the specified set of conditions.
 void setClamped()
          Set the clamped condition.
 void setConversionSyntax()
          Set the conversion syntax condition.
 void setDivisionByZero()
          Set the division by zero condition.
 void setDivisionImpossible()
          Set the division impossible condition.
 void setDivisionUndefined()
          Set the division undefined condition.
 void setInexact()
          Set the inexact condition.
 void setInsufficientStorage()
          Set the insufficient storage condition.
 void setInvalidContext()
          Set the invalid context condition.
 void setInvalidOperation()
          Set the invalid operation condition.
 void setLostDigits()
          Set the lost digits condition.
 void setOverflow()
          Set the overflow condition.
 void setRounded()
          Set the rounded condition.
 void setSubnormal()
          Set the subnormal condition.
 void setUnderflow()
          Set the underflow condition.
 java.lang.String toCompactString()
          Represent the set conditions as a compact string, using a single letter for each set condition.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArithmeticConditions

public ArithmeticConditions()
Create a set of arithmetic conditions. Initially, all conditions are reset.

Method Detail

isClamped

public boolean isClamped()
Return true if the clamped condition is set. The clamped condition indicates that an exponent was adjusted to bring it into the range of encodable values. If the coefficient was non-zero, it will have been adjusted correspondingly by adding trailing zeroes.


setClamped

public void setClamped()
Set the clamped condition.

See Also:
isClamped()

isConversionSyntax

public boolean isConversionSyntax()
Return true if the conversion syntax condition is set.


setConversionSyntax

public void setConversionSyntax()
Set the conversion syntax condition.

See Also:
isConversionSyntax()

isDivisionByZero

public boolean isDivisionByZero()
Return true if the division by zero condition is set.


setDivisionByZero

public void setDivisionByZero()
Set the division by zero condition.

See Also:
isDivisionByZero()

isDivisionImpossible

public boolean isDivisionImpossible()
Return true if the division impossible condition is set.


setDivisionImpossible

public void setDivisionImpossible()
Set the division impossible condition.

See Also:
isDivisionImpossible()

isDivisionUndefined

public boolean isDivisionUndefined()
Return true if the division undefined condition is set.


setDivisionUndefined

public void setDivisionUndefined()
Set the division undefined condition.

See Also:
isDivisionUndefined()

isInexact

public boolean isInexact()
Return true if the inexact condition is set. The inexact condition indicates that an adjustment that was necessary to make a number encodable has resulted in an encoding that is not exactly the original number. This may occur because of rounding of non-zero trailing digits, or because of overflows or underflows to infinities or zeroes.


setInexact

public void setInexact()
Set the inexact condition.

See Also:
isInexact()

isInsufficientStorage

public boolean isInsufficientStorage()
Return true if the insufficient storage condition is set.


setInsufficientStorage

public void setInsufficientStorage()
Set the insufficient storage condition.

See Also:
isInsufficientStorage()

isInvalidContext

public boolean isInvalidContext()
Return true if the invalid context condition is set.


setInvalidContext

public void setInvalidContext()
Set the invalid context condition.

See Also:
isInvalidContext()

isInvalidOperation

public boolean isInvalidOperation()
Return true if the invalid operation condition is set.


setInvalidOperation

public void setInvalidOperation()
Set the invalid operation condition.

See Also:
isInvalidOperation()

isLostDigits

public boolean isLostDigits()
Return true if the lost digits condition is set.


setLostDigits

public void setLostDigits()
Set the lost digits condition.

See Also:
isLostDigits()

isOverflow

public boolean isOverflow()
Return true if the overflow condition is set. The overflow condition indicates that the magnitude of a number was greater than or equal to the normal range upper threshold, possibly after applying necessary rounding. When the overflow condition is set, the resultant encoding will generally be an infinity, although certain values near to the normal range upper threshold may combine with certain rounding methods to set the overflow condition while still yielding a finite encoding.


setOverflow

public void setOverflow()
Set the overflow condition.

See Also:
isOverflow()

isRounded

public boolean isRounded()
Return true if the rounded condition is set. The rounded condition indicates that a coefficient was shortened to bring it into the range of encodable coefficient lengths. The exponent will also have been adjusted correspondingly. If there were trailing zeroes on the original coefficient, it is possible for the rounded condition to be set without the resultant encoding being inexact.


setRounded

public void setRounded()
Set the rounded condition.

See Also:
isRounded()

isSubnormal

public boolean isSubnormal()
Return true if the subnormal condition is set. The subnormal condition indicates that the number was finite and non-zero and had a magnitude less than the normal range lower threshold. Some subnormal numbers can be accommodated in the encoding, although there is less precision available than for numbers in the normal range. If the number can be accommodated exactly in this way, the subnormal condition will be set. If rounding had to be applied, or if the number was out of the range of encodable subnormal numbers, then the inexact condition will be set, along with the underflow condition. Note that the resultant encoding may not be a subnormal number when the subnormal condition is set.


setSubnormal

public void setSubnormal()
Set the subnormal condition.

See Also:
isSubnormal()

isUnderflow

public boolean isUnderflow()
Return true if the underflow condition is set. The underflow condition generally indicates that the magnitude of a number is less than the normal range lower threshold and could not be exactly encoded. The resultant encoding may be a zero or one of the small-magnitude finite encodings described as subnormal, although certain values near to the normal range lower threshold may combine with certain rounding methods to set the underflow condition while still yielding a finite encoding in the normal range.


setUnderflow

public void setUnderflow()
Set the underflow condition.

See Also:
isUnderflow()

setAll

public void setAll(ArithmeticConditions conditions)
Set all the conditions which are set in the specified set of conditions.


resetAll

public void resetAll()
Clear all the conditions.


toCompactString

public java.lang.String toCompactString()
Represent the set conditions as a compact string, using a single letter for each set condition. The letters used are as follows: If no conditions are set, the string "-" is returned.


equals

public boolean equals(java.lang.Object other)
Return true if the conditions all match.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Return a hash code which will be equal for objects that compare equal, and will preferably be different for objects that compare unequal.

Overrides:
hashCode in class java.lang.Object