activemq-cpp-3.6.0
decaf::lang::Float Class Reference

#include <src/main/decaf/lang/Float.h>

Inheritance diagram for decaf::lang::Float:

Public Member Functions

 Float (float value)
 Float (double value)
 Float (const std::string &value)
virtual ~Float ()
virtual int compareTo (const Float &f) const
 Compares this Float instance with another.
bool equals (const Float &f) const
virtual bool operator== (const Float &f) const
 Compares equality between this object and the one passed.
virtual bool operator< (const Float &f) const
 Compares this object to another and returns true if this object is considered to be less than the one passed.
virtual int compareTo (const float &f) const
 Compares this Float instance with another.
bool equals (const float &f) const
virtual bool operator== (const float &f) const
 Compares equality between this object and the one passed.
virtual bool operator< (const float &f) const
 Compares this object to another and returns true if this object is considered to be less than the one passed.
std::string toString () const
virtual double doubleValue () const
 Answers the double value which the receiver represents.
virtual float floatValue () const
 Answers the float value which the receiver represents.
virtual unsigned char byteValue () const
 Answers the byte value which the receiver represents.
virtual short shortValue () const
 Answers the short value which the receiver represents.
virtual int intValue () const
 Answers the int value which the receiver represents.
virtual long long longValue () const
 Answers the long value which the receiver represents.
bool isInfinite () const
bool isNaN () const
- Public Member Functions inherited from decaf::lang::Number
virtual ~Number ()
- Public Member Functions inherited from decaf::lang::Comparable< Float >
virtual ~Comparable ()
- Public Member Functions inherited from decaf::lang::Comparable< float >
virtual ~Comparable ()

Static Public Member Functions

static int compare (float f1, float f2)
 Compares the two specified double values.
static int floatToIntBits (float value)
 Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout.
static int floatToRawIntBits (float value)
 Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout, preserving Not-a-Number (NaN) values.
static float intBitsToFloat (int bits)
 Returns the float value corresponding to a given bit representation.
static bool isInfinite (float value)
static bool isNaN (float value)
static float parseFloat (const std::string &value)
 Returns a new float initialized to the value represented by the specified string, as performed by the valueOf method of class Float.
static std::string toHexString (float value)
 Returns a hexadecimal string representation of the float argument.
static std::string toString (float value)
 Returns a string representation of the float argument.
static Float valueOf (float value)
 Returns a Float instance representing the specified float value.
static Float valueOf (const std::string &value)
 Returns a Float instance that wraps a primitive float which is parsed from the string value passed.

Static Public Attributes

static const int SIZE = 32
 The size in bits of the primitive int type.
static const float MAX_VALUE
 The maximum value that the primitive type can hold.
static const float MIN_VALUE
 The minimum value that the primitive type can hold.
static const float NaN
 Constant for the Not a Number Value.
static const float POSITIVE_INFINITY
 Constant for Positive Infinity.
static const float NEGATIVE_INFINITY
 Constant for Negative Infinity.

Constructor & Destructor Documentation

decaf::lang::Float::Float ( float  value)
Parameters
value- the primitive type to wrap
decaf::lang::Float::Float ( double  value)
Parameters
value- the primitive type to wrap
decaf::lang::Float::Float ( const std::string &  value)
Parameters
value- the string to convert to a primitive type to wrap
virtual decaf::lang::Float::~Float ( )
inlinevirtual

Member Function Documentation

virtual unsigned char decaf::lang::Float::byteValue ( ) const
inlinevirtual

Answers the byte value which the receiver represents.

Returns
byte the value of the receiver.

Reimplemented from decaf::lang::Number.

static int decaf::lang::Float::compare ( float  f1,
float  f2 
)
static

Compares the two specified double values.

The sign of the integer value returned is the same as that of the integer that would be returned by the call: Float( f1 ).compareTo( Float( f2) )

Parameters
f1- the first double to compare
f2- the second double to compare
Returns
the value 0 if d1 is numerically equal to f2; a value less than 0 if f1 is numerically less than f2; and a value greater than 0 if f1 is numerically greater than f2.
virtual int decaf::lang::Float::compareTo ( const Float f) const
virtual

Compares this Float instance with another.

Parameters
f- the Float instance to be compared
Returns
zero if this object represents the same integer value as the argument; a positive value if this object represents a value greater than the passed in value, and -1 if this object represents a value less than the passed in value.

Implements decaf::lang::Comparable< Float >.

virtual int decaf::lang::Float::compareTo ( const float &  f) const
virtual

Compares this Float instance with another.

Parameters
f- the Float instance to be compared
Returns
zero if this object represents the same integer value as the argument; a positive value if this object represents a value greater than the passed in value, and -1 if this object represents a value less than the passed in value.

Implements decaf::lang::Comparable< float >.

virtual double decaf::lang::Float::doubleValue ( ) const
inlinevirtual

Answers the double value which the receiver represents.

Returns
double the value of the receiver.

Implements decaf::lang::Number.

bool decaf::lang::Float::equals ( const Float f) const
inlinevirtual
Parameters
f- the Float object to compare against.
Returns
true if the two Float Objects have the same value.

Implements decaf::lang::Comparable< Float >.

bool decaf::lang::Float::equals ( const float &  f) const
inlinevirtual
Parameters
f- the Float object to compare against.
Returns
true if the two Float Objects have the same value.

Implements decaf::lang::Comparable< float >.

static int decaf::lang::Float::floatToIntBits ( float  value)
static

Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout.

Bit 31 (the bit that is selected by the mask 0x80000000) represents the sign of the floating-point number. Bits 30-23 (the bits that are selected by the mask 0x7f800000) represent the exponent. Bits 22-0 (the bits that are selected by the mask 0x007fffff) represent the significand (sometimes called the mantissa) of the floating-point number.

If the argument is positive infinity, the result is 0x7f800000. If the argument is negative infinity, the result is 0xff800000. If the argument is NaN, the result is 0x7fc00000.

In all cases, the result is an integer that, when given to the intBitsToFloat(int) method, will produce a floating-point value the same as the argument to floatToIntBits (except all NaN values are collapsed to a single "canonical" NaN value).

Parameters
value- the float to convert to int bits
Returns
the int that holds the float's value

Referenced by decaf::util::HashCode< float >::operator()().

static int decaf::lang::Float::floatToRawIntBits ( float  value)
static

Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout, preserving Not-a-Number (NaN) values.

Bit 31 (the bit that is selected by the mask 0x80000000) represents the sign of the floating-point number. Bits 30-23 (the bits that are selected by the mask 0x7f800000) represent the exponent. Bits 22-0 (the bits that are selected by the mask 0x007fffff) represent the significand (sometimes called the mantissa) of the floating-point number.

If the argument is positive infinity, the result is 0x7f800000. If the argument is negative infinity, the result is 0xff800000. If the argument is NaN, the result is the integer representing the actual NaN value. Unlike the floatToIntBits method, intToRawIntBits does not collapse all the bit patterns encoding a NaN to a single "canonical" NaN value.

In all cases, the result is an integer that, when given to the intBitsToFloat(int) method, will produce a floating-point value the same as the argument to floatToRawIntBits.

Parameters
valueThe float to convert to a raw int.
Returns
the raw int value of the float
virtual float decaf::lang::Float::floatValue ( ) const
inlinevirtual

Answers the float value which the receiver represents.

Returns
float the value of the receiver.

Implements decaf::lang::Number.

static float decaf::lang::Float::intBitsToFloat ( int  bits)
static

Returns the float value corresponding to a given bit representation.

The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "single format" bit layout.

If the argument is 0x7f800000, the result is positive infinity. If the argument is 0xff800000, the result is negative infinity. If the argument is any value in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 0xffffffff, the result is a NaN. No IEEE 754 floating-point operation provided by C++ can distinguish between two NaN values of the same type with different bit patterns. Distinct values of NaN are only distinguishable by use of the Float::floatToRawIntBits method.

Parameters
bits- the bits of the float encoded as a float
Returns
a new float created from the int bits.
virtual int decaf::lang::Float::intValue ( ) const
inlinevirtual

Answers the int value which the receiver represents.

Returns
int the value of the receiver.

Implements decaf::lang::Number.

bool decaf::lang::Float::isInfinite ( ) const
Returns
true if the float is equal to positive infinity.
static bool decaf::lang::Float::isInfinite ( float  value)
static
Parameters
value- The float to check.
Returns
true if the float is equal to infinity.
bool decaf::lang::Float::isNaN ( ) const
Returns
true if the float is equal to NaN.
static bool decaf::lang::Float::isNaN ( float  value)
static
Parameters
value- The float to check.
Returns
true if the float is equal to NaN.
virtual long long decaf::lang::Float::longValue ( ) const
inlinevirtual

Answers the long value which the receiver represents.

Returns
long the value of the receiver.

Implements decaf::lang::Number.

virtual bool decaf::lang::Float::operator< ( const Float f) const
inlinevirtual

Compares this object to another and returns true if this object is considered to be less than the one passed.

This

Parameters
f- the value to be compared to this one.
Returns
true if this object is equal to the one passed.

Implements decaf::lang::Comparable< Float >.

virtual bool decaf::lang::Float::operator< ( const float &  f) const
inlinevirtual

Compares this object to another and returns true if this object is considered to be less than the one passed.

This

Parameters
f- the value to be compared to this one.
Returns
true if this object is equal to the one passed.

Implements decaf::lang::Comparable< float >.

virtual bool decaf::lang::Float::operator== ( const Float f) const
inlinevirtual

Compares equality between this object and the one passed.

Parameters
f- the value to be compared to this one.
Returns
true if this object is equal to the one passed.

Implements decaf::lang::Comparable< Float >.

virtual bool decaf::lang::Float::operator== ( const float &  f) const
inlinevirtual

Compares equality between this object and the one passed.

Parameters
f- the value to be compared to this one.
Returns
true if this object is equal to the one passed.

Implements decaf::lang::Comparable< float >.

static float decaf::lang::Float::parseFloat ( const std::string &  value)
static

Returns a new float initialized to the value represented by the specified string, as performed by the valueOf method of class Float.

Parameters
value- the string to parse
Returns
a float parsed from the string
Exceptions
NumberFormatException
virtual short decaf::lang::Float::shortValue ( ) const
inlinevirtual

Answers the short value which the receiver represents.

Returns
short the value of the receiver.

Reimplemented from decaf::lang::Number.

static std::string decaf::lang::Float::toHexString ( float  value)
static

Returns a hexadecimal string representation of the float argument.

All characters mentioned below are ASCII characters.

  • If the argument is NaN, the result is the string "NaN".
  • Otherwise, the result is a string that represents the sign and magnitude (absolute value) of the argument. If the sign is negative, the first character of the result is '-'; if the sign is positive, no sign character appears in the result. As for the magnitude m: o If m is infinity, it is represented by the string "Infinity"; thus, positive infinity produces the result "Infinity" and negative infinity produces the result "-Infinity". o If m is zero, it is represented by the string "0x0.0p0"; thus, negative zero produces the result "-0x0.0p0" and positive zero produces the result "0x0.0p0". o If m is a float value with a normalized representation, substrings are used to represent the significand and exponent fields. The significand is represented by the characters "0x1." followed by a lowercase hexadecimal representation of the rest of the significand as a fraction. Trailing zeros in the hexadecimal representation are removed unless all the digits are zero, in which case a single zero is used. Next, the exponent is represented by "p" followed by a decimal string of the unbiased exponent as if produced by a call to Integer.toString on the exponent value. o If m is a float value with a subnormal representation, the significand is represented by the characters "0x0." followed by a hexadecimal representation of the rest of the significand as a fraction. Trailing zeros in the hexadecimal representation are removed. Next, the exponent is represented by "p-126". Note that there must be at least one nonzero digit in a subnormal significand.
Parameters
value- The float to convert to a string
Returns
the Hex formatted float string.
std::string decaf::lang::Float::toString ( ) const
Returns
this Float Object as a String Representation
static std::string decaf::lang::Float::toString ( float  value)
static

Returns a string representation of the float argument.

All characters mentioned below are ASCII characters.

If the argument is NaN, the result is the string "NaN". Otherwise, the result is a string that represents the sign and magnitude (absolute value) of the argument. If the sign is negative, the first character of the result is '-'; if the sign is positive, no sign character appears in the result. As for the magnitude m: o If m is infinity, it is represented by the characters "Infinity"; thus, positive infinity produces the result "Infinity" and negative infinity produces the result "-Infinity". o If m is zero, it is represented by the characters "0.0"; thus, negative zero produces the result "-0.0" and positive zero produces the result "0.0". o If m is greater than or equal to 10-3 but less than 107, then it is represented as the integer part of m, in decimal form with no leading zeroes, followed by '.', followed by one or more decimal digits representing the fractional part of m. o If m is less than 10-3 or greater than or equal to 107, then it is represented in so-called "computerized scientific notation." Let n be the unique integer such that 10n <= m < 10n+1; then let a be the mathematically exact quotient of m and 10n so that 1 <= a < 10. The magnitude is then represented as the integer part of a, as a single decimal digit, followed by '.', followed by decimal digits representing the fractional part of a, followed by the letter 'E', followed by a representation of n as a decimal integer, as produced by the method Integer.toString(int).

Parameters
value- The float to convert to a string
Returns
the formatted float string.
static Float decaf::lang::Float::valueOf ( float  value)
static

Returns a Float instance representing the specified float value.

Parameters
value- float to wrap
Returns
new Float instance wrapping the primitive value
static Float decaf::lang::Float::valueOf ( const std::string &  value)
static

Returns a Float instance that wraps a primitive float which is parsed from the string value passed.

Parameters
value- the string to parse
Returns
a new Float instance wrapping the float parsed from value
Exceptions
NumberFormatExceptionon error.

Field Documentation

const float decaf::lang::Float::MAX_VALUE
static

The maximum value that the primitive type can hold.

const float decaf::lang::Float::MIN_VALUE
static

The minimum value that the primitive type can hold.

const float decaf::lang::Float::NaN
static

Constant for the Not a Number Value.

const float decaf::lang::Float::NEGATIVE_INFINITY
static

Constant for Negative Infinity.

const float decaf::lang::Float::POSITIVE_INFINITY
static

Constant for Positive Infinity.

const int decaf::lang::Float::SIZE = 32
static

The size in bits of the primitive int type.


The documentation for this class was generated from the following file: