Package com.amazon.ion
Interface IonFloat
-
public interface IonFloat extends IonNumber
An Ionfloatvalue.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 usedecimalvalues instead. Please read the Decimal Arithmetic FAQ for horror stories.If you have any doubt whatsoever on whether you should use
floatordecimal, then you should usedecimal.- See Also:
IonDecimal
-
-
Field Summary
-
Fields inherited from interface com.amazon.ion.IonValue
EMPTY_ARRAY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.math.BigDecimalbigDecimalValue()Gets the value of this Ionfloatas a JavaBigDecimal.IonFloatclone()Creates a copy of this value and all of its children.doubledoubleValue()Gets the value of this Ionfloatas a Javadoublevalue.floatfloatValue()Gets the value of this Ionfloatas a Javafloatvalue.booleanisNumericValue()Determines whether this value is numeric.voidsetValue(double value)Sets the value of this element.voidsetValue(float value)Sets the value of this element.voidsetValue(java.math.BigDecimal value)Sets the value of this element.-
Methods inherited from interface com.amazon.ion.IonValue
accept, addTypeAnnotation, clearTypeAnnotations, equals, getContainer, getFieldId, getFieldName, getFieldNameSymbol, getSymbolTable, getSystem, getType, getTypeAnnotations, getTypeAnnotationSymbols, hashCode, hasTypeAnnotation, isNullValue, isReadOnly, makeReadOnly, removeFromContainer, removeTypeAnnotation, setTypeAnnotations, setTypeAnnotationSymbols, topLevelValue, toPrettyString, toString, toString, writeTo
-
-
-
-
Method Detail
-
floatValue
float floatValue() throws NullValueExceptionGets the value of this Ionfloatas a Javafloatvalue.- Returns:
- the float value.
- Throws:
NullValueException- ifthis.isNullValue().
-
doubleValue
double doubleValue() throws NullValueExceptionGets the value of this Ionfloatas a Javadoublevalue.- Returns:
- the double value.
- Throws:
NullValueException- ifthis.isNullValue().
-
bigDecimalValue
java.math.BigDecimal bigDecimalValue() throws NullValueExceptionGets the value of this Ionfloatas a JavaBigDecimal. This follows the behavior ofBigDecimal.valueOf(double). It's recommended to callisNumericValue()before calling this method. If you need negative zeros, usedoubleValue().- Specified by:
bigDecimalValuein interfaceIonNumber- Returns:
- the
BigDecimalvalue, ornullifthis.isNullValue(). - Throws:
java.lang.NumberFormatException- if this value isnan,+inf, or-inf, becauseBigDecimalcannot represent those values.NullValueException
-
setValue
void setValue(float value)
Sets the value of this element.
-
setValue
void setValue(double value)
Sets the value of this element.
-
setValue
void setValue(java.math.BigDecimal value)
Sets the value of this element. Since Ionfloats are essentially Javadoubles, this performs a narrowing conversion as described byBigDecimal.doubleValue().- Parameters:
value- the new value of this float; may benullto make thisnull.float.
-
isNumericValue
boolean isNumericValue()
Determines whether this value is numeric. Returns true if this value is none ofnull,nan,+inf, and-inf, and false if it is any of them.- Specified by:
isNumericValuein interfaceIonNumber- Returns:
- a checked condition whether this value is numeric.
-
clone
IonFloat clone() throws UnknownSymbolException
Description copied from interface:IonValueCreates 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 instanceIonValue.isReadOnly().The cloned value will be created in the context of the same
ValueFactoryas this instance; if you want a copy using a different factory, then useValueFactory.clone(IonValue)instead.- Specified by:
clonein interfaceIonValue- Throws:
UnknownSymbolException- if any part of this value has unknown text but known Sid for its field name, annotation or symbol.
-
-