Float Class

Definition

The Float class wraps a value of primitive type float in an object.

[Android.Runtime.Register("java/lang/Float", DoNotGenerateAcw=true)]
public sealed class Float : Java.Lang.Number, IConvertible, IDisposable, Java.Interop.IJavaPeerable, Java.Lang.IComparable
[<Android.Runtime.Register("java/lang/Float", DoNotGenerateAcw=true)>]
type Float = class
    inherit Number
    interface IConvertible
    interface IComparable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
Attributes
Implements

Remarks

The Float class wraps a value of primitive type float in an object. An object of type Float contains a single field whose type is float.

In addition, this class provides several methods for converting a float to a String and a String to a float, as well as other constants and methods useful when dealing with a float.

<!-- Android-removed: paragraph on ValueBased

This is a value-based class; programmers should treat instances that are #equals(Object) equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail. -->

<h2>equivalenceRelation>Floating-point Equality, Equivalence, and Comparison</h2>

The class java.lang.Double has a discussion of equality, equivalence, and comparison of floating-point values that is equally applicable to float values.

Added in 1.0.

Java documentation for java.lang.Float.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Name Description
Float(Double)

Constructs a newly allocated Float object that represents the argument converted to type float.

Float(Single)

Constructs a newly allocated Float object that represents the primitive float argument.

Float(String)

Constructs a newly allocated Float object that represents the floating-point value of type float represented by the string.

Fields

Name Description
Bytes

The number of bytes used to represent a float value.

MaxExponent

Maximum exponent a finite float variable may have.

MinExponent

Minimum exponent a normalized float variable may have.

MinNormal

A constant holding the smallest positive normal value of type float, 2<sup>-126</sup>.

Precision

The number of bits in the significand of a float value.

Size

The number of bits used to represent a float value.

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsInfinite

Returns true if this Float value is infinitely large in magnitude, false otherwise.

IsNaN

Returns true if this Float value is a Not-a-Number (NaN), false otherwise.

JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniPeerMembers

Gets the JNI metadata used to invoke members of this Java peer.

PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Number)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Number)
Type

The Class instance representing the primitive type float.

Methods

Name Description
ByteValue()

Returns the value of the specified number as a byte.

(Inherited from Number)
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Compare(Single, Single)

Compares the two specified float values.

CompareTo(Float)

Compares two Float objects numerically.

Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DoubleValue()

Returns the value of this Float as a double after a widening primitive conversion.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Float16ToFloat(Int16)

{

FloatToFloat16(Single)

{

FloatToIntBits(Single)

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

FloatToRawIntBits(Single)

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.

FloatValue()

Returns the float value of this Float object.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
HashCode(Single)

Returns a hash code for a float value; compatible with Float.hashCode().

IntBitsToFloat(Int32)

Returns the float value corresponding to a given bit representation.

IntValue()

Returns the value of this Float as an int after a narrowing primitive conversion.

InvokeIsInfinite(Single)

Returns true if the specified number is infinitely large in magnitude, false otherwise.

InvokeIsNaN(Single)

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

IsFinite(Single)

Returns true if the argument is a finite floating-point value; returns false otherwise (for NaN and infinity arguments).

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
LongValue()

Returns value of this Float as a long after a narrowing primitive conversion.

Max(Single, Single)

Returns the greater of two float values as if by calling Math#max(float, float) Math.max.

Min(Single, Single)

Returns the smaller of two float values as if by calling Math#min(float, float) Math.min.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
ParseFloat(String)

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

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ShortValue()

Returns the value of the specified number as a short.

(Inherited from Number)
Sum(Single, Single)

Adds two float values together as per the + operator.

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToHexString(Single)

Returns a hexadecimal string representation of the float argument.

ToString()

Returns a string representation of the object.

(Inherited from Object)
ToString(Single)

Returns a string representation of the float argument.

UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
ValueOf(Single)

Returns a Float instance representing the specified float value.

ValueOf(String)

Returns a Float object holding the float value represented by the argument string s.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Operators

Name Description
Explicit(Float to Single)

Converts the specified Float value to Single.

Explicit Interface Implementations

Name Description
IComparable.CompareTo(Object)

Compares this value with the specified object for ordering.

IConvertible.GetTypeCode()

Returns the type code for this value.

IConvertible.ToBoolean(IFormatProvider)

Converts this value to Boolean.

IConvertible.ToByte(IFormatProvider)

Converts this value to Byte.

IConvertible.ToChar(IFormatProvider)

Converts this value to Char.

IConvertible.ToDateTime(IFormatProvider)

Conversion to DateTime is unsupported and throws InvalidCastException.

IConvertible.ToDecimal(IFormatProvider)

Converts this value to Decimal.

IConvertible.ToDouble(IFormatProvider)

Converts this value to Double.

IConvertible.ToInt16(IFormatProvider)

Converts this value to Int16.

IConvertible.ToInt32(IFormatProvider)

Converts this value to Int32.

IConvertible.ToInt64(IFormatProvider)

Converts this value to Int64.

IConvertible.ToSByte(IFormatProvider)

Converts this value to SByte.

IConvertible.ToSingle(IFormatProvider)

Converts this value to Single.

IConvertible.ToString(IFormatProvider)

Converts this value to String.

IConvertible.ToType(Type, IFormatProvider)

Converts this value to the type specified by conversionType.

IConvertible.ToUInt16(IFormatProvider)

Converts this value to UInt16.

IConvertible.ToUInt32(IFormatProvider)

Converts this value to UInt32.

IConvertible.ToUInt64(IFormatProvider)

Converts this value to UInt64.

IJavaPeerable.Disposed()

Notifies the interop runtime that this managed peer has been disposed.

(Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced()

Releases this Java peer unless it is retained by another managed reference.

(Inherited from Object)
IJavaPeerable.Finalized()

Notifies the interop runtime that this managed peer has been finalized.

(Inherited from Object)
IJavaPeerable.JniManagedPeerState

Gets the state that describes the relationship between this managed peer and its JNI reference.

(Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32)

Sets the interop identity hash code for this Java peer.

(Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

Sets the managed and JNI peer state for this Java peer.

(Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference)

Sets the JNI object reference used by this managed peer.

(Inherited from Object)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to