

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object java.lang.Number byucc.jhdl.Logic.Modules.FloatingPoint.helpers.FloatingPoint
Immutable customprecision floatingpoint numbers
Field Summary  
protected boolean 
isInfinite

protected boolean 
isNaN

Constructor Summary  
protected 
FloatingPoint(double dval,
java.lang.Object objval,
int numExponentBits,
int numMantissaBits)
Base constructorcalls initialize 
Method Summary  
FloatingPoint 
abs()
Returns the absolute value of this FloatingPoint 
FloatingPoint 
add(FloatingPoint val)
Returns the sum of two FloatingPoints. 
java.lang.Object 
clone()

int 
compareTo_g(FloatingPoint val)
Compares two FloatingPoints. 
int 
compareTo_l(FloatingPoint val)
Compares two FloatingPoints. 
int 
compareTo(FloatingPoint val)
Compares two FloatingPoints. 
static FloatingPoint 
create(java.math.BigDecimal val,
FloatingPoint prototype)
Constructs a FloatingPoint with the same numbers of bits as and the same class as prototype . 
static FloatingPoint 
create(java.math.BigDecimal val,
int numExponentBits,
int numMantissaBits)
Constructs a FloatingPoint number with the specified numbers of bits. 
static FloatingPoint 
create(java.math.BigDecimal val,
int numExponentBits,
int numMantissaBits,
FloatingPoint prototype)
Constructs a FloatingPoint number with the specified numbers of bits. 
static FloatingPoint 
create(double val,
FloatingPoint prototype)
Constructs a FloatingPoint with the same numbers of bits and the same class as prototype . 
static FloatingPoint 
create(double val,
int numExponentBits,
int numMantissaBits)
Constructs a FloatingPoint with the specified numbers of bits. 
static FloatingPoint 
create(double val,
int numExponentBits,
int numMantissaBits,
FloatingPoint prototype)
Constructs a FloatingPoint with the specified numbers of bits of the same class as prototype . 
static FloatingPoint 
create(FloatingPoint val,
FloatingPoint prototype)
Constructs a FloatingPoint with the same value as val and
the same numbers of bits
and class as prototype . 
static FloatingPoint 
create(FloatingPoint val,
int numExponentBits,
int numMantissaBits)
Constructs a FloatingPoint number with the specified numbers of bits. 
static FloatingPoint 
create(FloatingPoint val,
int numExponentBits,
int numMantissaBits,
FloatingPoint prototype)
Constructs a FloatingPoint number with the specified numbers of bits and the same class as prototype . 
static FloatingPoint 
create(long val,
FloatingPoint prototype)
Constructs a FloatingPoint with the same numbers of bits and the same class as prototype . 
static FloatingPoint 
create(long val,
int numExponentBits,
int numMantissaBits)
Constructs a FloatingPoint with the specified numbers of bits. 
static FloatingPoint 
create(long val,
int numExponentBits,
int numMantissaBits,
FloatingPoint prototype)
Constructs a FloatingPoint with the specified numbers of bits and the same class as prototype . 
static FloatingPoint 
create(java.lang.String str)
Constructs a FloatingPoint from a string 
static FloatingPoint 
create(java.lang.String str,
FloatingPoint prototype)
Constructs a FloatingPoint from a string of the same class as prototype . 
FloatingPoint 
divide(FloatingPoint val)
Returns the quotient of two FloatingPoints. 
double 
doubleValue()
Converts this FloatingPoint to a double. 
boolean 
equals(java.lang.Object o)
Compares this FloatingPoint number with the specified Object for equality. 
float 
floatValue()
Converts this FloatingPoint to a float. 
protected int 
getExponent()
Returns the unbiased exponent 
int 
getNumExponentBits()
Returns the number of exponent bits 
int 
getNumMantissaBits()
Returns the number of mantissa bits 
int 
getSign()
Returns 1 or 1 to indicate the sign bit 
protected java.math.BigInteger 
getSignificand()
Returns the significand as represented internally: a positive BigInteger. 
protected void 
handleOverflow()
Handles the condition where the exponent is greater than the number of exponent bits can represent. 
protected void 
handleUnderflow()
Handles the condition where the exponent is less than the number of exponent bits can represent. 
int 
intValue()
Converts this FloatingPoint to a int. 
boolean 
isInfinite()

boolean 
isNaN()

long 
longValue()
Converts this FloatingPoint to a long. 
FloatingPoint 
multiply(FloatingPoint val)
Returns the product of two FloatingPoints. 
FloatingPoint 
negate()
Returns the FloatingPoint whose value is the opposite of the value of this 
FloatingPoint 
remainder(FloatingPoint val)
Returns the remainder of this FloatingPoint divided by another (that is, this % val ). 
int 
signum()
Returns 1, 0, or 1 as the value of this FloatingPoint is negative, zero, or positive, respectively 
FloatingPoint 
subtract(FloatingPoint val)
Returns the difference of two FloatingPoints. 
java.math.BigDecimal 
toBigDecimal()
Converts this FloatingPoint to a BigDecimal. 
java.lang.String 
toBinaryString()
Returns a string representing the value of this FloatingPoint and showing its bits. 
java.lang.String 
toString()
Uses toBigDecimal except for special cases like infinity 
Methods inherited from class java.lang.Number 
byteValue, shortValue 
Methods inherited from class java.lang.Object 
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
Field Detail 
protected boolean isInfinite
protected boolean isNaN
Constructor Detail 
protected FloatingPoint(double dval, java.lang.Object objval, int numExponentBits, int numMantissaBits)
Method Detail 
public static FloatingPoint create(double val, int numExponentBits, int numMantissaBits)
val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(long val, int numExponentBits, int numMantissaBits)
val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(java.math.BigDecimal val, int numExponentBits, int numMantissaBits)
val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(FloatingPoint val, int numExponentBits, int numMantissaBits)
val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(java.lang.String str) throws java.lang.NumberFormatException
The string may contain a binary or hexadecimal representation of the value. The radix depends on the digits used. If the significand and exponent parts of the string contain only ones and zeroes, both the significand and the exponent are parsed as binary numbers, unless the first two characters of the string are "0x". If these two characters are present, or if either the significand or exponent part of the string contains digits besides ones and zeroes, both the significand and the exponent are parsed as hexadecimal numbers.
The number of bits used is determined from the numbers of digits in the string and the radix. If hexadecimal strings are given, the numbers of bits in the exponent and the mantissa will be multiples of four. Note that the digit that precedes the point will be treated specially when the radix is hexadecimal, because it corresponds to the hidden bit, so it can only be 1 or 0.
This is the format of the string:
"0xH.MMMM EEEE"
. The 0x is the optional
hexadecimal prefix. Negative numbers must have a minus sign before the
significand. Positive numbers are indicated by the absence of the minus
sign, never by a plus sign. H represents the hidden bit, which
must be given explicitly. The M's represent the bits of the mantissa,
and the E's are the bits of the biased exponent.
java.lang.NumberFormatException
public static FloatingPoint create(double val, int numExponentBits, int numMantissaBits, FloatingPoint prototype)
prototype
.
Similar to the doubletofloat
narrowing primitive conversion defined in The Java Language
Specification: if val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(double val, FloatingPoint prototype)
prototype
.
Similar to the doubletofloat
narrowing primitive conversion defined in The Java Language
Specification: if val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(long val, int numExponentBits, int numMantissaBits, FloatingPoint prototype)
prototype
.
Similar to the doubletofloat
narrowing primitive conversion defined in The Java Language
Specification: if val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(long val, FloatingPoint prototype)
prototype
.
Similar to the doubletofloat
narrowing primitive conversion defined in The Java Language
Specification: if val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(java.math.BigDecimal val, int numExponentBits, int numMantissaBits, FloatingPoint prototype)
prototype
.
Similar to the doubletofloat
narrowing primitive conversion defined in The Java Language
Specification: if val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(java.math.BigDecimal val, FloatingPoint prototype)
prototype
.
Similar to the doubletofloat
narrowing primitive conversion defined in The Java Language
Specification: if val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(FloatingPoint val, int numExponentBits, int numMantissaBits, FloatingPoint prototype)
prototype
.
Similar to the doubletofloat
narrowing primitive conversion defined in The Java Language
Specification: if val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(FloatingPoint val, FloatingPoint prototype)
val
and
the same numbers of bits
and class as prototype
.
Similar to the doubletofloat
narrowing primitive conversion defined in The Java Language
Specification: if val
has too great a magnitude to
represent with the specified number of bits in the exponent, the
FloatingPoint represents positive or negative infinity instead.
If the number of bits in the mantissa cannot represent val
exactly, rounding is performed according to the
roundtowardnearesteven mode as specified in the IEEE 754 standard.
public static FloatingPoint create(java.lang.String str, FloatingPoint prototype) throws java.lang.NumberFormatException
prototype
.
The string may contain a binary or hexadecimal representation of the value. The radix depends on the digits used. If the significand and exponent parts of the string contain only ones and zeroes, both the significand and the exponent are parsed as binary numbers, unless the first two characters of the string are "0x". If these two characters are present, or if either the significand or exponent part of the string contains digits besides ones and zeroes, both the significand and the exponent are parsed as hexadecimal numbers.
The number of bits used is determined from the numbers of digits in the string and the radix. If hexadecimal strings are given, the numbers of bits in the exponent and the mantissa will be multiples of four. Note that the digit that precedes the point will be treated specially when the radix is hexadecimal, because it corresponds to the hidden bit, so it can only be 1 or 0.
This is the format of the string:
"0xH.MMMM EEEE"
. The 0x is the optional
hexadecimal prefix. Negative numbers must have a minus sign before the
significand. Positive numbers are indicated by the absence of the minus
sign, never by a plus sign. H represents the hidden bit, which
must be given explicitly. The M's represent the bits of the mantissa,
and the E's are the bits of the biased exponent.
java.lang.NumberFormatException
public java.lang.Object clone()
protected void handleOverflow()
sign
field is not changed.
protected void handleUnderflow()
sign
field is not changed.
protected int getExponent()
public int getNumExponentBits()
public int getNumMantissaBits()
public int getSign()
protected java.math.BigInteger getSignificand()
public boolean isInfinite()
public boolean isNaN()
public int intValue()
FloatingPointException
 if this FloatingPoint represents
an infinite value or NaNpublic long longValue()
public float floatValue()
Float.NEGATIVE_INFINITY
or
Float.POSITIVE_INFINITY
, as appropriate.
public double doubleValue()
Double.NEGATIVE_INFINITY
or
Double.POSITIVE_INFINITY
, as appropriate.
public java.lang.String toString()
toBigDecimal
except for special cases like infinity
public java.lang.String toBinaryString()
The output of this method is compatible with the
create(String)
.
public java.math.BigDecimal toBigDecimal()
FloatingPointException
 if this FloatingPoint represents an
infinite value or NaNpublic FloatingPoint add(FloatingPoint val)
val
 value to be added to this FloatingPoint
this + val
public FloatingPoint subtract(FloatingPoint val)
val
 value to be subtracted from this FloatingPoint
this  val
public FloatingPoint multiply(FloatingPoint val)
val
 value by which this FloatingPoint is to be multiplied
this * val
public FloatingPoint divide(FloatingPoint val)
val
 value by which this FloatingPoint is to be divided
this / val
public FloatingPoint remainder(FloatingPoint val)
this
% val
).
The FloatingPoint returned has as many exponent bits as whichever
of the two FloatingPoints has more exponent bits, and as many
mantissa bits as whichever of the two has more mantissa bits.
val
 value by which this FloatingPoint is to be divided
this / val
public FloatingPoint negate()
this
public int signum()
FloatingPointException
 if this FloatingPoint represents NaNpublic FloatingPoint abs()
public boolean equals(java.lang.Object o)
compareTo_g
and
compareTo_l
in the following ways:
public int compareTo(FloatingPoint val)
this is less than, equal to, or
greater than val
, respectively.
Throws:
FloatingPointException
 if either FloatingPoint represents NaN
compareTo_g
public int compareTo_g(FloatingPoint val)
 Compares two FloatingPoints. This method compares FloatingPoints the same
way that the bytecode instructions
fcmpg
and
dcmpg
compare floats and doubles, respectively: If either
of the two FloatingPoints represent NaN, it returns 1.
 Returns:
 1, 0, or 1 as
this is less than, equal to, or
greater than val
, respectively. Returns 1 if either number
is NaN
compareTo_l
public int compareTo_l(FloatingPoint val)
 Compares two FloatingPoints. This method compares FloatingPoints the same
way that the bytecode instructions
fcmpl
and
dcmpl
compare floats and doubles, respectively: If either
of the two FloatingPoints represent NaN, it returns 1.
 Returns:
 1, 0, or 1 as
this is less than, equal to, or
greater than val
, respectively. Returns 1 if either number
is NaN
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED  FIELD  CONSTR  METHOD
DETAIL: FIELD  CONSTR  METHOD
Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.