Top Description Methods
com.amazon.ion

public Interface IonFloat

extends IonNumber
Known Direct Implementers
com.amazon.ion.impl.lite.IonFloatLite
Imports
java.math.BigDecimal

An Ion float value.

Warning

This interface should not be implemented or extended by code outside of this library.

Precision Problems

Use of binary floating-point numbers is prone to countless problems. The vast majority of applications should use decimal values instead. Please read the Decimal Arithmetic FAQ for horror stories.

If you have any doubt whatsoever on whether you should use float or decimal, then you should use decimal.

See Also
IonDecimal

Method Summary

Modifier and TypeMethod and Description
public BigDecimal

Returns:

the BigDecimal value, or null if this.isNullValue().
bigDecimalValue
()

Redeclares com.amazon.ion.IonNumber.bigDecimalValue.

Gets the value of this Ion float as a Java BigDecimal.

public IonFloat
clone()

Redeclares com.amazon.ion.IonValue.clone.

Creates a copy of this value and all of its children.

public double

Returns:

the double value.
doubleValue
()

Gets the value of this Ion float as a Java double value.

public float

Returns:

the float value.
floatValue
()

Gets the value of this Ion float as a Java float value.

public boolean

Returns:

a checked condition whether this value is numeric.
isNumericValue
()

Redeclares com.amazon.ion.IonNumber.isNumericValue.

Determines whether this value is numeric.

public void
setValue(float value)

Sets the value of this element.

public void
setValue(double value)

Sets the value of this element.

public void
setValue(BigDecimal
the new value of this float; may be null to make this null.float.
value
)

Sets the value of this element.

Method Detail

bigDecimalValueback to summary
public BigDecimal bigDecimalValue() throws NullValueException

Redeclares com.amazon.ion.IonNumber.bigDecimalValue.

Gets the value of this Ion float as a Java BigDecimal. This follows the behavior of BigDecimal#valueOf(double). It's recommended to call IonFloat#isNumericValue() before calling this method. If you need negative zeros, use doubleValue().

Returns:BigDecimal

the BigDecimal value, or null if this.isNullValue().

Annotations
@Override
Exceptions
NumberFormatException:
if this value is nan, +inf, or -inf, because BigDecimal cannot represent those values.
cloneback to summary
public IonFloat clone() throws UnknownSymbolException

Redeclares com.amazon.ion.IonValue.clone.

Doc from com.amazon.ion.IonValue.clone.

Creates a copy of this value and all of its children. The cloned value may use the same shared symbol tables, but it will have an independent local symbol table if necessary. The cloned value will be modifiable regardless of whether this instance isReadOnly().

The cloned value will be created in the context of the same ValueFactory as this instance; if you want a copy using a different factory, then use ValueFactory#clone(IonValue) instead.

Exceptions
UnknownSymbolException:
if any part of this value has unknown text but known Sid for its field name, annotation or symbol.
doubleValueback to summary
public double doubleValue() throws NullValueException

Gets the value of this Ion float as a Java double value.

Returns:double

the double value.

Exceptions
NullValueException:
if this.isNullValue().
floatValueback to summary
public float floatValue() throws NullValueException

Gets the value of this Ion float as a Java float value.

Returns:float

the float value.

Exceptions
NullValueException:
if this.isNullValue().
isNumericValueback to summary
public boolean isNumericValue()

Redeclares com.amazon.ion.IonNumber.isNumericValue.

Determines whether this value is numeric. Returns true if this value is none of null, nan, +inf, and -inf, and false if it is any of them.

Returns:boolean

a checked condition whether this value is numeric.

setValueback to summary
public void setValue(float value)

Sets the value of this element.

setValueback to summary
public void setValue(double value)

Sets the value of this element.

setValueback to summary
public void setValue(BigDecimal value)

Sets the value of this element. Since Ion floats are essentially Java doubles, this performs a narrowing conversion as described by BigDecimal#doubleValue().

Parameters
value:BigDecimal

the new value of this float; may be null to make this null.float.