Mono Class Library: System NamespaceSystem.Single Structure |
See Also: Single Members
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
float is a 32-bit single precision floating-point type that represents values ranging from approximately 1.5E-45 to 3.4E+38 and from approximately -1.5E-45 to -3.4E+38 with a precision of 7 decimal digits. The float type conforms to standard IEC 60559:1989, Binary Floating-point Arithmetic for Microprocessor Systems.
A float can represent the following values:
- The finite set of non-zero values of the form s * m * 2e, where s is 1 or -1, and 0 < m < 224 and -149 <= e <= 104.
- Positive infinity and negative infinity. Infinities are produced by operations that produce results with a magnitude greater than that which can be represented by a float, such as dividing a non-zero number by zero. For example, using float operands, 1.0 / 0.0 yields positive infinity, and -1.0 / 0.0 yields negative infinity. Operations include passing parameters and returning values.
- The Not-a-Number value (NaN). NaN values are produced by invalid floating-point operations, such as dividing zero by zero.
When performing binary operations, if one of the operands is a floating-point type (double or float ), then the other operand is required to be an integral type or a floating-point type and the operation is evaluated as follows:
- If one of the operands is of an integral type, then that operand is converted to the floating-point type of the other operand.
- Then, if either of the operands is of type double, the other operand is converted to double, and the operation is performed using at least the range and precision of the double type. For numeric operations, the type of the result is double.
- Otherwise, the operation is performed using at least the range and precision of the float type and, for numeric operations, the type of the result is float.
The floating-point operators, including the assignment operators, do not throw exceptions. Instead, in exceptional situations, the result of a floating-point operation is zero, infinity, or NaN, as described below:
- If the result of a floating-point operation is too small for the destination format, the result of the operation is zero.
- If the magnitude of the result of a floating-point operation is too large for the destination format, the result of the operation is positive infinity or negative infinity.
- If a floating-point operation is invalid, the result of the operation is NaN.
- If one or both operands of a floating-point operation are NaN, the result of the operation is NaN.
Conforming implementations of the CLI are permitted to perform floating-point operations using a precision that is higher than that required by the float type. For example, hardware architectures that support an "extended" or "long double" floating-point type with greater range and precision than the float type could implicitly perform all floating-point operations using this higher precision type. Expressions evaluated using a higher precision might cause a finite result to be produced instead of an infinity.
[Edit]
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0