toPrimitiveFloat()

Converts an object or primitive data type to the primitive float data type.

Syntax

float toPrimitiveFloat(Object objectData)
float toPrimitiveFloat(int integerData)
float toPrimitiveFloat(double doubleData)

Parameters

objectData
A Java object. The objects currently supported are: Double, Float, Integer, and String.
integerData
Any primitive int variable.
doubleData
Any primitive double variable.

Return values

Returns a primitive float value.

Exceptions

DtpIncompatibleFormatException - If the source data type cannot be converted to float.

Notes

This method can only handle String, Integer, Float, and Double objects; and there will be some data loss when the input type is Double.

The limitation of this method is the same as the limitation of the float type in Java.

The largest positive finite float literal is 3.40282347e+38f. The smallest positive finite nonzero literal of type float is 1.40239846e-45f, with 6-7 significant figures. Values above 99,999.99 should not be used with this data type.

Examples

float myFloat = DtpDataConversion.toPrimitiveFloat(myInteger);

See also

getType(), isOKToConvert(), toFloat()

For more information, see the Java Language Specification.

Copyright IBM Corp. 2004, 2005