ExtendedNumerics mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.ValueType System.IComparable System.IComparable<System.Single> System.IConvertible System.IEquatable<System.Single> System.IFormattable System.Runtime.InteropServices.ComVisible(true)

The value type represents a single-precision 32-bit number with values ranging from negative 3.402823e38 to positive 3.402823e38, as well as positive or negative zero, , , and not a number (). It is intended to represent values that are extremely large (such as distances between planets or galaxies) or extremely small (such as the molecular mass of a substance in kilograms) and that often are imprecise (such as the distance from earth to another solar system). The type complies with the IEC 60559:1989 (IEEE 754) standard for binary floating-point arithmetic.

This topic consists of the following sections:

Floating-point representation and precision

Testing for equality

Floating-point values and exceptions

Floating-point functionality

provides methods to compare instances of this type, to convert the value of an instance to its string representation, and to convert the string representation of a number to an instance of this type. For information about how format specification codes control the string representation of value types, see Formatting Types, Standard Numeric Format Strings, and Custom Numeric Format Strings.

## Floating-point representation and precision

The data type stores single-precision floating-point values in a 32-bit binary format, as shown in the following table:

Part

Bits

Significand or mantissa

0-22

Exponent

23-30

Sign (0 = positive, 1 = negative)

31

Just as decimal fractions are unable to precisely represent some fractional values (such as 1/3 or ), binary fractions are unable to represent some fractional values. For example, 2/10, which is represented precisely by .2 as a decimal fraction, is represented by .0011111001001100 as a binary fraction, with the pattern "1100" repeating to infinity. In this case, the floating-point value provides an imprecise representation of the number that it represents. Performing additional mathematical operations on the original floating-point value often increases its lack of precision. For example, if you compare the results of multiplying .3 by 10 and adding .3 to .3 nine times, you will see that addition produces the less precise result, because it involves eight more operations than multiplication. Note that this disparity is apparent only if you display the two values by using the "R" standard numeric format string, which, if necessary, displays all 9 digits of precision supported by the type.

code reference: System.Single.Structure#3

Because some numbers cannot be represented exactly as fractional binary values, floating-point numbers can only approximate real numbers.

All floating-point numbers have a limited number of significant digits, which also determines how accurately a floating-point value approximates a real number. A value has up to 7 decimal digits of precision, although a maximum of 9 digits is maintained internally. This means that some floating-point operations may lack the precision to change a floating-point value. The following example defines a large single-precision floating-point value, and then adds the product of and one quadrillion to it. However, the product is too small to modify the original floating-point value. Its least significant digit is thousandths, whereas the most significant digit in the product is 1-312.

code reference: System.Single.Structure#4

The limited precision of a floating-point number has several consequences:

Two floating-point numbers that appear equal for a particular precision might not compare equal because their least significant digits are different. In the following example, a series of numbers are added together, and their total is compared with their expected total. Although the two values appear to be the same, a call to the Equals method indicates that they are not.

code reference: System.Single.Structure#6

If you change the format items in the statement from {0} and {1} to {0:R} and {1:R} to display all significant digits of the two values, it is clear that the two values are unequal because of a loss of precision during the addition operations. In this case, the issue can be resolved by calling the method to round the values to the desired precision before performing the comparison.

A mathematical or comparison operation that uses a floating-point number might not yield the same result if a decimal number is used, because the binary floating-point number might not equal the decimal number. A previous example illustrated this by displaying the result of multiplying .3 by 10 and adding .3 to .3 nine times.

When accuracy in numeric operations with fractional values is important, use the type instead of the type. When accuracy in numeric operations with integral values beyond the range of the or types is important, use the type.

A value might not round-trip if a floating-point number is involved. A value is said to round-trip if an operation converts an original floating-point number to another form, an inverse operation transforms the converted form back to a floating-point number, and the final floating-point number is not equal to the original floating-point number. The round trip might fail because one or more least significant digits are lost or changed in a conversion. In the following example, three values are converted to strings and saved in a file. As the output shows, although the values appear to be identical, the restored values are not equal to the original values.

code reference: System.Single.Structure#7

In this case, the values can be successfully round-tripped by using the "R" standard numeric format string to preserve the full precision of values, as the following example shows.

code reference: System.Single.Structure#8

values have less precision than values. A value that is converted to a seemingly equivalent often does not equal the value because of differences in precision. In the following example, the result of identical division operations is assigned to a value and a value. After the value is cast to a , a comparison of the two values shows that they are unequal.

code reference: System.Double.Structure#5

To avoid this problem, either use the data type in place of the data type, or use the method so that both values have the same precision.

## Testing for equality

To be considered equal, two values must represent identical values. However, because of differences in precision between values, or because of a loss of precision by one or both values, floating-point values that are expected to be identical often turn out to be unequal due to differences in their least significant digits. As a result, calls to the method to determine whether two values are equal, or calls to the method to determine the relationship between two values, often yield unexpected results. This is evident in the following example, where two apparently equal values turn out to be unequal, because the first value has 7 digits of precision, whereas the second value has 9.

code reference: System.Single.Structure#9

Calculated values that follow different code paths and that are manipulated in different ways often prove to be unequal. In the following example, one value is squared, and then the square root is calculated to restore the original value. A second is multiplied by 3.51 and squared before the square root of the result is divided by 3.51 to restore the original value. Although the two values appear to be identical, a call to the method indicates that they are not equal. Using the "R" standard format string to return a result string that displays all the significant digits of each value shows that the second value is .0000000000001 less than the first.

code reference: System.Single.Structure#10

In cases where a loss of precision is likely to affect the result of a comparison, you can use the following techniques instead of calling the or method:

Call the method to ensure that both values have the same precision. The following example modifies a previous example to use this approach so that two fractional values are equivalent.

code reference: System.Single.Structure#11

Note that the problem of precision still applies to rounding of midpoint values. For more information, see the method.

Test for approximate equality instead of equality. This technique requires that you define either an absolute amount by which the two values can differ but still be equal, or that you define a relative amount by which the smaller value can diverge from the larger value.

is sometimes used as an absolute measure of the distance between two values when testing for equality. However, measures the smallest possible value that can be added to, or subtracted from, a whose value is zero. For most positive and negative values, the value of is too small to be detected. Therefore, except for values that are zero, we do not recommend its use in tests for equality.

The following example uses the latter approach to define an IsApproximatelyEqual method that tests the relative difference between two values. It also contrasts the result of calls to the IsApproximatelyEqual method and the method.

code reference: System.Single.Structure#12

## Floating-point values and exceptions

Operations with floating-point values do not throw exceptions, unlike operations with integral types, which throw exceptions in cases of illegal operations such as division by zero or overflow. Instead, in these situations, the result of a floating-point operation is zero, positive infinity, negative infinity, or not a number (NaN):

If the result of a floating-point operation is too small for the destination format, the result is zero. This can occur when two very small floating-point numbers are multiplied, as the following example shows.

code reference: System.Single.Structure#1

If the magnitude of the result of a floating-point operation exceeds the range of the destination format, the result of the operation is or , as appropriate for the sign of the result. The result of an operation that overflows is , and the result of an operation that overflows is , as the following example shows.

code reference: System.Single.Structure#2

also results from a division by zero with a positive dividend, and results from a division by zero with a negative dividend.

If a floating-point operation is invalid, the result of the operation is . For example, results from the following operations:

Division by zero with a dividend of zero. Note that other cases of division by zero result in either or .

Any floating-point operation with invalid input. For example, attempting to find the square root of a negative value returns .

Any operation with an argument whose value is .

## Floating-point functionality

The structure and related types provide methods to perform the following categories of operations:

Comparison of values. You can call the method to determine whether two values are equal, or the method to determine the relationship between two values.

The structure also supports a complete set of comparison operators. For example, you can test for equality or inequality, or determine whether one value is greater than or equal to another value. If one of the operands is a , the value is converted to a before performing the comparison. If one of the operands is an integral type, it is converted to a before performing the comparison. Although these are widening conversions, they may involve a loss of precision.

Because of differences in precision, two values that you expect to be equal may turn out to be unequal, which affects the result of the comparison. See the Testing for equality section for more information about comparing two values.

You can also call the , , , and methods to test for these special values.

Mathematical operations. Common arithmetic operations such as addition, subtraction, multiplication, and division are implemented by language compilers and Common Intermediate Language (CIL) instructions rather than by methods. If the other operand in a mathematical operation is a , the is converted to a before performing the operation, and the result of the operation is also a value. If the other operand is an integral type, it is converted to a before performing the operation, and the result of the operation is also a value.

You can perform other mathematical operations by calling static (Shared in Visual Basic) methods in the class. These include additional methods commonly used for arithmetic (such as , , and ), geometry (such as and ), and calculus (such as ). In all cases, the value is converted to a .

You can also manipulate the individual bits in a value. The method returns its bit pattern in a byte array. By passing that byte array to the method, you can also preserve the value's bit pattern in a 32-bit integer.

Rounding. Rounding is often used as a technique for reducing the impact of differences between values caused by problems of floating-point representation and precision. You can round a value by calling the method. However, note that the value is converted to a before the method is called, and the conversion can involve a loss of precision.

Formatting. You can convert a value to its string representation by calling the method or by using the composite formatting feature. For information about how format strings control the string representation of floating-point values, see the Standard Numeric Format Strings and Custom Numeric Format Strings topics.

Parsing strings. You can convert the string representation of a floating-point value to a value by calling the or method. If the parse operation fails, the method throws an exception, whereas the method returns false.

Type conversion. The structure provides an explicit interface implementation for the interface, which supports conversion between any two standard .NET Framework data types. Language compilers also support the implicit conversion of values for all other standard numeric types except for the conversion of to values. Conversion of a value of any standard numeric type other than a to a is a widening conversion and does not require the use of a casting operator or conversion method.

However, conversion of 32-bit and 64-bit integer values can involve a loss of precision. The following table lists the differences in precision for 32-bit, 64-bit, and types:

Type

Maximum precision (in decimal digits)

Internal precision (in decimal digits)

15

17

and

10

10

and

19

19

7

9

The problem of precision most frequently affects values that are converted to values. In the following example, two values produced by identical division operations are unequal, because one of the values is a single-precision floating point value that is converted to a .

code reference: System.Single.Structure#5

Represents a single-precision floating-point number.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` is not a null reference and is not of type .

  The parameter must be null or an instance of ; otherwise, an exception is thrown. Any instance of , regardless of its value, is considered greater than null.

  Values must be identical to be considered equal. Particularly when floating-point values depend on multiple mathematical operations, it is common for them to lose precision and for their values to be nearly identical except for their least significant digits. Because of this, the return value of the method may seem surprising at times. For example, multiplication by a particular value followed by division by the same value should produce the original value, but in the following example, the computed value turns out to be greater than the original value. Showing all significant digits of the two values by using the "R" standard numeric format string indicates that the computed value differs from the original value in its least significant digits. For information about handling such comparisons, see the Remarks section of the method.

  code reference: System.Single.CompareTo#2

  This method is implemented to support the interface. Note that, although a is not considered to be equal to another (even itself), the interface requires that A.CompareTo(A) return zero.

  ## Precision in Comparisons

  The precision of floating-point numbers beyond the documented precision is specific to the implementation and version of the .NET Framework. Consequently, a comparison of two particular numbers might change between versions of the .NET Framework because the precision of the numbers' internal representation might change.

  Compares this instance to a specified object and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified object.

  A signed number indicating the relative values of this instance and .

  Return Value

  Description

  Less than zero

  This instance is less than .

  -or-

  This instance is not a number () and is a number.

  Zero

  This instance is equal to .

  -or-

  This instance and value are both not a number (), , or .

  Greater than zero

  This instance is greater than .

  -or-

  This instance is a number and is not a number ().

  -or-

  is null.

  An object to compare, or null. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  Values must be identical to be considered equal. It is common for floating-point values to lose precision and to become nearly identical except for their least significant digits, especially when the values depend on multiple mathematical operations. Because of this, the return value of the method at times may seem surprising. For example, multiplication by any value followed by division by the same value should produce the original value. However, in the following example, the computed value turns out to be greater than the original value. Showing all significant digits of the two values by using the "R" standard numeric format string indicates that the computed value differs from the original value in its least significant digits. For information about handling such comparisons, see the Remarks section of the method.

  code reference: System.Single.CompareTo#1

  This method implements the interface and performs slightly better than the method because it does not have to convert the parameter to an object.

  Note that, although an object whose value is is not considered equal to another object whose value is (even itself), the interface requires that A.CompareTo(A) return zero.

  ## Widening Conversions

  Depending on your programming language, it might be possible to code a method where the parameter type has fewer bits (is narrower) than the instance type. This is possible because some programming languages perform an implicit widening conversion that represents the parameter as a type with as many bits as the instance.

  For example, suppose the instance type is and the parameter type is . The Microsoft C# compiler generates instructions to represent the value of the parameter as a object, then generates a method that compares the values of the instance and the widened representation of the parameter.

  Consult your programming language's documentation to determine if its compiler performs implicit widening conversions of numeric types. For more information, see the Type Conversion Tables topic.

  ## Precision in Comparisons

  The precision of floating-point numbers beyond the documented precision is specific to the implementation and version of the .NET Framework. Consequently, a comparison of two particular numbers might change between versions of the .NET Framework because the precision of the numbers' internal representation might change.

  Compares this instance to a specified single-precision floating-point number and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified single-precision floating-point number.

  A signed number indicating the relative values of this instance and .

  Return Value

  Description

  Less than zero

  This instance is less than .

  -or-

  This instance is not a number () and is a number.

  Zero

  This instance is equal to .

  -or-

  Both this instance and are not a number (), , or .

  Greater than zero

  This instance is greater than .

  -or-

  This instance is a number and is not a number ().

  A single-precision floating-point number to compare.
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single 1.401298E-45

  The value of the property reflects the smallest positive value that is significant in numeric operations or comparisons when the value of the instance is zero. For example, the following code shows that zero and are considered to be unequal values, whereas zero and half the value of are considered to be equal.

  code reference: System.Single.Epsilon#5

  More precisely, the single-precision floating-point format consists of a sign, a 23-bit mantissa or significand, and an 8-bit exponent. As the following example shows, zero has an exponent of -126 and a mantissa of 0. has an exponent of -126 and a mantissa of 1. This means that is the smallest positive value that is greater than zero and represents the smallest possible value and the smallest possible increment for a whose exponent is -126.

  code reference: System.Single.Epsilon#6

  However, the property is not a general measure of precision of the type; it applies only to instances that have a value of zero.

  The value of the property is not equivalent to machine epsilon, which represents the upper bound of the relative error due to rounding in floating-point arithmetic.

  The value of this constant is 1.4e-45.

  Two apparently equivalent floating-point numbers might not compare equal because of differences in their least significant digits. For example, the C# expression, (float)1/3 == (float)0.33333, does not compare equal because the division operation on the left side has maximum precision while the constant on the right side is precise only to the specified digits. If you create a custom algorithm that determines whether two floating-point numbers can be considered equal, you must use a value that is greater than the constant to establish the acceptable absolute margin of difference for the two values to be considered equal. (Typically, that margin of difference is many times greater than .)

  ## Platform Notes

  On ARM systems, the value of the constant is too small to be detected, so it equates to zero. You can define an alternative epsilon value that equals 1.175494351E-38 instead.

  Represents the smallest positive value that is greater than zero. This field is constant.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  The method should be used with caution, because two apparently equivalent values can be unequal due to the differing precision of the two values. The following example reports that the value .3333 and the returned by dividing 1 by 3 are unequal.

  code reference: System.Single.Epsilon#3

  Rather than comparing for equality, one recommended technique involves defining an acceptable margin of difference between two values (such as .01% of one of the values). If the absolute value of the difference between the two values is less than or equal to that margin, the difference is likely to be due to differences in precision and, therefore, the values are likely to be equal. The following example uses this technique to compare .33333 and 1/3, the two values that the previous code example found to be unequal.

  code reference: System.Single.Epsilon#4

  In this case, the values are equal.

  Because defines the minimum expression of a positive value whose range is near zero, the margin of difference must be greater than . Typically, it is many times greater than .

  The precision of floating-point numbers beyond the documented precision is specific to the implementation and version of the .NET Framework. Consequently, a comparison of two particular numbers might change between versions of the .NET Framework because the precision of the numbers' internal representation might change.

  Returns a value indicating whether this instance is equal to a specified object.

  true if is an instance of and equals the value of this instance; otherwise, false.

  An object to compare with this instance. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This method implements the interface, and performs slightly better than because it does not have to convert the parameter to an object.

  ## Widening Conversions

  Depending on your programming language, it might be possible to code an method where the parameter type has fewer bits (is narrower) than the instance type. This is possible because some programming languages perform an implicit widening conversion that represents the parameter as a type with as many bits as the instance.

  For example, suppose the instance type is and the parameter type is . The Microsoft C# compiler generates instructions to represent the value of the parameter as a object, and then generates a method that compares the values of the instance and the widened representation of the parameter.

  Consult your programming language's documentation to determine if its compiler performs implicit widening conversions of numeric types. For more information, see the Type Conversion Tables topic.

  ## Precision in Comparisons

  The method should be used with caution, because two apparently equivalent values can be unequal because of the differing precision of the two values. The following example reports that the value .3333 and the returned by dividing 1 by 3 are unequal.

  code reference: System.Single.Epsilon#1

  One comparison technique that avoids the problems associated with comparing for equality involves defining an acceptable margin of difference between two values (such as .01% of one of the values). If the absolute value of the difference between the two values is less than or equal to that margin, the difference is likely to be an outcome of differences in precision and, therefore, the values are likely to be equal. The following example uses this technique to compare .33333 and 1/3, which are the two values that the previous code example found to be unequal.

  code reference: System.Single.Epsilon#2

  In this case, the values are equal.

  Because defines the minimum expression of a positive value whose range is near zero, the margin of difference must be greater than . Typically, it is many times greater than . Because of this, we recommend that you do not use when comparing values for equality.

  A second technique that avoids the problems associated with comparing for equality involves comparing the difference between two floating-point numbers with some absolute value. If the difference is less than or equal to that absolute value, the numbers are equal. If it is greater, the numbers are not equal. One way to do this is to arbitrarily select an absolute value. However, this is problematic, because an acceptable margin of difference depends on the magnitude of the values. A second way takes advantage of a design feature of the floating-point format: The difference between the mantissa components in the integer representations of two floating-point values indicates the number of possible floating-point values that separates the two values. For example, the difference between 0.0 and is 1, because is the smallest representable value when working with a whose value is zero. The following example uses this technique to compare .33333 and 1/3, which are the two values that the previous code example with the method found to be unequal. Note that the example uses the and methods to convert a single-precision floating-point value to its integer representation.

  code reference: System.Single.Equals#1

  The precision of floating-point numbers beyond the documented precision is specific to the implementation and version of the .NET Framework. Consequently, a comparison of two numbers might produce different results depending on the version of the .NET Framework, because the precision of the numbers' internal representation might change.

  Returns a value indicating whether this instance and a specified object represent the same value.

  true if is equal to this instance; otherwise, false.

  An object to compare with this instance.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  The algorithm used to generate the hash code is unspecified.

  This method overrides .

  Returns the hash code for this instance.

  A 32-bit signed integer hash code.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TypeCode To be added.

  Returns the for value type .

  The enumerated constant, .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  Floating-point operations return or to signal an overflow condition.

  Returns a value indicating whether the specified number evaluates to negative or positive infinity.

  true if evaluates to or ; otherwise, false.

  A single-precision floating-point number. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Boolean ``

  Floating-point operations return to signal that that result of the operation is undefined. For example, dividing 0.0 by 0.0 results in .

  returns false if a value is either or . To test for these values, use the , , and methods.

  Returns a value that indicates whether the specified value is not a number ().

  true if evaluates to not a number (); otherwise, false.

  A single-precision floating-point number. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  Floating-point operations return to signal an overflow condition.

  Returns a value indicating whether the specified number evaluates to negative infinity.

  true if evaluates to ; otherwise, false.

  A single-precision floating-point number. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  Floating-point operations return to signal an overflow condition.

  Returns a value indicating whether the specified number evaluates to positive infinity.

  true if evaluates to ; otherwise, false.

  A single-precision floating-point number. 0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single 3.402823E+38

  The value of this constant is positive 3.402823e38.

  The result of an operation that exceeds is . In the following example, results from addition, multiplication, and exponentiation operations when the result exceeds .

  code reference: System.Single.MaxValue#1

  Represents the largest possible value of . This field is constant.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single -3.402823E+38

  The value of this constant is negative 3.402823e38.

  The result of an operation that is less than is . In the following example, results from subtraction and multiplication operations when the result is less than .

  code reference: System.Single.MinValue#1

  Represents the smallest possible value of . This field is constant.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single NaN

  A method or operator returns when the result of an operation is undefined. For example, the result of dividing zero by zero is , as the following example shows. (But note that dividing a non-zero number by zero returns either or , depending on the sign of the divisor.)

  code reference: System.Single.NaN#1

  In addition, a method call with a value or an operation on a value returns , as the following example shows.

  code reference: System.Single.NaN#2

  Use the method to determine whether a value is not a number. Two values are considered unequal to one another. Therefore, it is not possible to determine whether a value is not a number by using the equality operator to compare it to another value that is equal to NaN. The comparison returns false, as the following example shows.

  code reference: System.Single.NaN#3

  Represents not a number (NaN). This field is constant.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single -Infinity

  The value of this constant is the result of dividing a negative number by zero.

  This constant is returned when the result of an operation is less than .

  Use to determine whether a value evaluates to negative infinity.

  Represents negative infinity. This field is constant.

  0
- Method
  4.0.0.0
  System.Boolean `` ``

  The method defines the equality operator for values.

  Returns a value that indicates whether two specified values are equal.

  true if and are equal; otherwise, false.

  The first value to compare. The second value to compare.
- Method
  4.0.0.0
  System.Boolean `` ``

  The method defines the operation of the greater-than operator for values.

  Returns a value that indicates whether a specified value is greater than another specified value.

  true if is greater than ; otherwise, false.

  The first value to compare. The second value to compare.
- Method
  4.0.0.0
  System.Boolean `` ``

  The method defines the operation of the greater-than-or-equal operator for values.

  Returns a value that indicates whether a specified value is greater than or equal to another specified value.

  true if is greater than or equal to ; otherwise, false.

  The first value to compare. The second value to compare.
- Method
  4.0.0.0
  System.Boolean `` ``

  The method defines the inequality operator for values.

  Returns a value that indicates whether two specified values are not equal.

  true if and are not equal; otherwise, false.

  The first value to compare. The second value to compare.
- Method
  4.0.0.0
  System.Boolean `` ``

  The method defines the operation of the less-than operator for values.

  Returns a value that indicates whether a specified value is less than another specified value.

  true if is less than ; otherwise, false.

  The first value to compare. The second value to compare.
- Method
  4.0.0.0
  System.Boolean `` ``

  The method defines the operation of the less-than-or-equal operator for values.

  Returns a value that indicates whether a specified value is less than or equal to another specified value.

  true if is less than or equal to ; otherwise, false.

  The first value to compare. The second value to compare.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single `` is a null reference. is not in the correct style. represents a value that is less than or greater than .

  The parameter can contain the current culture's , , , or a string of the form:

  [ws][sign] [integral-digits[,]]integral-digits[.[fractional-digits]][e[sign]exponential-digits][ws]

  Elements in square brackets ([ and ]) are optional. The following table describes each element.

  Element

  Description

  ws

  A series of white space characters.

  sign

  A negative sign symbol or a positive sign symbol. Valid sign characters are determined by the and properties of the current culture. Only a leading sign can be used.

  integral-digits

  A series of digits ranging from 0 to 9 that specify the integral part of the number. Runs of integral-digits can be partitioned by a group-separator symbol. For example, in some cultures a comma (,) separates groups of thousands. The integral-digits element can be absent if the string contains the fractional-digits element.

  ,

  A culture-specific thousands separator symbol.

  .

  A culture-specific decimal point symbol.

  fractional-digits

  A series of digits ranging from 0 to 9 that specify the fractional part of the number.

  E

  The "e" or "E" character, which indicates that the value is represented in exponential (scientific) notation.

  exponential-digits

  A series of digits ranging from 0 to 9 that specify an exponent.

  The parameter is interpreted using a combination of the and flags. This means that white space and thousands separators are allowed but currency symbols are not. To explicitly define the elements (such as currency symbols, thousands separators, and white space) that can be present in , use the method overload.

  The parameter is parsed by using the formatting information in a object that is initialized for the current system culture. For more information, see . To parse a string by using the formatting information of a specific culture, use the or method.

  Ordinarily, if you pass the method a string that is created by calling the method, the original value is returned. However, because of a loss of precision, the values may not be equal.

  If a separator is encountered in the parameter during a parse operation, and the applicable currency or number decimal and group separators are the same, the parse operation assumes that the separator is a decimal separator rather than a group separator. For more information about separators, see , , , and .

  Converts the string representation of a number to its single-precision floating-point number equivalent.

  A single-precision floating-point number equivalent to the numeric value or symbol specified in .

  A string that contains a number to convert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single `` `` is a null reference. is not in the correct style. represents a value that is less than or greater than .

  The parameter defines the style elements (such as white space, thousands separators, and currency symbols) that are allowed in the parameter for the parse operation to succeed. It must be a combination of bit flags from the enumeration. The following members are not supported:

  The parameter can contain the current culture's , , . Depending on the value of , it can also take the form:

  [ws][$][sign][integral-digits[,]]integral-digits[.[fractional-digits]][E[sign]exponential-digits][ws]

  Elements in square brackets ([ and ]) are optional. The following table describes each element.

  ws

  A series of white-space characters. White space can appear at the beginning of if includes the flag, and it can appear at the end of if includes the flag.

  $

  A culture-specific currency symbol. Its position in the string is defined by the and properties of the current culture. The current culture's currency symbol can appear in if includes the flag.

  sign

  A negative sign symbol (-) or a positive sign symbol (+). The sign can appear at the beginning of if includes the flag, and it can appear at the end of if includes the flag. Parentheses can be used in to indicate a negative value if includes the flag.

  integral-digits

  A series of digits ranging from 0 to 9 that specify the integral part of the number. The integral-digits element can be absent if the string contains the fractional-digits element.

  ,

  A culture-specific group separator. The current culture's group separator symbol can appear in if includes the flag

  .

  A culture-specific decimal point symbol. The current culture's decimal point symbol can appear in if includes the flag.

  fractional-digits

  A series of digits ranging from 0 to 9 that specify the fractional part of the number. Fractional digits can appear in if includes the flag.

  E

  The "e" or "E" character, which indicates that the value is represented in exponential (scientific) notation. The parameter can represent a number in exponential notation if includes the flag.

  exponential-digits

  A series of digits ranging from 0 to 9 that specify an exponent.

  A string with digits only (which corresponds to the style) always parses successfully. The remaining members control elements that may be present, but are not required to be present, in the input string. The following table indicates how individual flags affect the elements that may be present in .

  NumberStyles value

  Elements permitted in in addition to digits

  The integral-digits element only.

  The decimal point (.) and fractional-digits elements.

  The "e" or "E" character, which indicates exponential notation. This flag by itself supports values in the form digitsEdigits; additional flags are needed to successfully parse strings with such elements as positive or negative signs and decimal point symbols.

  The ws element at the beginning of .

  The ws element at the end of .

  The sign element at the beginning of .

  The sign element at the end of .

  The sign element in the form of parentheses enclosing the numeric value.

  The thousands separator (,) element.

  The currency ($) element.

  All elements. However, cannot represent a hexadecimal number or a number in exponential notation.

  The ws element at the beginning or end of , sign at the beginning of , and the decimal point (.) symbol. The parameter can also use exponential notation.

  The , , thousands separator (,) and decimal point (.) elements.

  All elements. However, cannot represent a hexadecimal number.

  Some examples of are "100", "-123,456,789", "123.45e+6", "+500", "5e2", "3.1416", "600.", "-.123", and "-Infinity".

  The parameter is parsed using the formatting information in a object that is initialized for the current system culture. To specify the culture whose formatting information is used for the parse operation, call the overload.

  Ordinarily, if you pass the method a string that is created by calling the method, the original value is returned. However, because of a loss of precision, the values may not be equal.

  If a separator is encountered in the parameter during a parse operation, and the applicable currency or number decimal and group separators are the same, the parse operation assumes that the separator is a decimal separator rather than a group separator. For more information about separators, see , , , and .

  Converts the string representation of a number in a specified style to its single-precision floating-point number equivalent.

  A single-precision floating-point number that is equivalent to the numeric value or symbol specified in .

  A string that contains a number to convert. A bitwise combination of enumeration values that indicates the style elements that can be present in . A typical value to specify is combined with . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single `` `` is a null reference. is not in the correct style. represents a value that is less than or greater than .

  This overload is typically used to convert text that can be formatted in a variety of ways to a value. For example, it can be used to convert the text entered by a user into an HTML text box to a numeric value.

  The parameter is interpreted using a combination of the and flags. The parameter can contain , , or for the culture specified by , or it can contain a string of the form:

  [ws][sign]integral-digits[.[fractional-digits]][E[sign]exponential-digits][ws]

  Optional elements are framed in square brackets ([ and ]). Elements that contain the term "digits" consist of a series of numeric characters ranging from 0 to 9.

  Element

  Description

  ws

  A series of white-space characters.

  sign

  A negative sign symbol (-) or a positive sign symbol (+).

  integral-digits

  A series of digits ranging from 0 to 9 that specify the integral part of the number. Runs of integral-digits can be partitioned by a group-separator symbol. For example, in some cultures a comma (,) separates groups of thousands. The integral-digits element can be absent if the string contains the fractional-digits element.

  .

  A culture-specific decimal point symbol.

  fractional-digits

  A series of digits ranging from 0 to 9 that specify the fractional part of the number.

  E

  The "e" or "E" character, which indicates that the value is represented in exponential (scientific) notation.

  exponential-digits

  A series of digits ranging from 0 to 9 that specify an exponent.

  For more information about numeric formats, see the [<topic://cpConFormattingOverview>] topic.

  The parameter is an implementation whose method returns a object that provides culture-specific formatting information. When the method is invoked, it calls the parameter's method and passes it a object that represents the type. The method then returns the object that provides information about the format of the parameter. There are three ways to use the parameter to supply custom formatting information to the parse operation:

  You can pass a object that represents the culture that supplies formatting information. Its method returns the object that provides numeric formatting information for that culture.

  You can pass the actual object that provides numeric formatting information. (Its implementation of just returns itself.)

  You can pass a custom object that implements . Its method instantiates and returns the object that provides formatting information.

  If is null or a cannot be obtained, the formatting information for the current system culture is used.

  If a separator is encountered in the parameter during a parse operation, and the applicable currency or number decimal and group separators are the same, the parse operation assumes that the separator is a decimal separator rather than a group separator. For more information about separators, see , , , and .

  Some examples of are "100", "-123,456,789", "123.45e+6", "+500", "5e2", "3.1416", "600.", "-.123", and "-Infinity".

  Converts the string representation of a number in a specified culture-specific format to its single-precision floating-point number equivalent.

  A single-precision floating-point number equivalent to the numeric value or symbol specified in .

  A string that contains a number to convert. An object that supplies culture-specific formatting information about . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single `` `` `` is a null reference. is not in the correct style. represents a value that is less than or greater than .

  The parameter defines the style elements (such as white space, thousands separators, and currency symbols) that are allowed in the parameter for the parse operation to succeed. It must be a combination of bit flags from the enumeration. The following members are not supported:

  The parameter can contain , , or for the culture specified by . Depending on the value of , it can also take the form:

  [ws] [$] [sign][integral-digits,]integral-digits[.[fractional-digits]][E[sign]exponential-digits][ws]

  Elements framed in square brackets ([ and ]) are optional. The following table describes each element.

  Element

  Description

  ws

  A series of white-space characters. White space can appear at the beginning of if includes the flag, and it can appear at the end of if includes the flag.

  $

  A culture-specific currency symbol. Its position in the string is defined by the and properties of the current culture. The current culture's currency symbol can appear in if includes the flag.

  sign

  A negative sign symbol (-) or a positive sign symbol (+). The sign can appear at the beginning of if includes the flag, and it can appear at the end of if includes the flag. Parentheses can be used in to indicate a negative value if includes the flag.

  integral-digits

  A series of digits ranging from 0 to 9 that specify the integral part of the number. The integral-digits element can be absent if the string contains the fractional-digits element.

  ,

  A culture-specific group separator. The current culture's group separator symbol can appear in if includes the flag

  .

  A culture-specific decimal point symbol. The current culture's decimal point symbol can appear in if includes the flag.

  fractional-digits

  A series of digits ranging from 0 to 9 that specify the fractional part of the number. Fractional digits can appear in if includes the flag.

  E

  The "e" or "E" character, which indicates that the value is represented in exponential (scientific) notation. The parameter can represent a number in exponential notation if includes the flag.

  exponential-digits

  A series of digits ranging from 0 to 9 that specify an exponent.

  A string with digits only (which corresponds to the style) always parses successfully. The remaining members control elements that may be present, but are not required to be present, in the input string. The following table indicates how individual flags affect the elements that may be present in .

  NumberStyles value

  Elements permitted in in addition to digits

  The integral-digits element only.

  The decimal point (.) and fractional-digits elements.

  The "e" or "E" character, which indicates exponential notation. This flag by itself supports values in the form digitsEdigits; additional flags are needed to successfully parse strings with such elements as positive or negative signs and decimal point symbols.

  The ws element at the beginning of .

  The ws element at the end of .

  The sign element at the beginning of .

  The sign element at the end of .

  The sign element in the form of parentheses enclosing the numeric value.

  The thousands separator (,) element.

  The currency ($) element.

  All elements. However, cannot represent a hexadecimal number or a number in exponential notation.

  The ws element at the beginning or end of , sign at the beginning of , and the decimal point (.) symbol. The parameter can also use exponential notation.

  The , , thousands separator (,) and decimal point (.) elements.

  All elements. However, cannot represent a hexadecimal number.

  The parameter is an implementation. Its method returns a object that provides culture-specific information about the format of . Typically, can be any one of the following:

  A object that represents the culture that provides numeric formatting information. Its method returns the object that provides numeric formatting information.

  A object that provides formatting information. (Its implementation of just returns itself.)

  A custom object that implements and uses the method to instantiate and return the object that provides formatting information.

  If is null, the object for the current culture is used.

  If a separator is encountered in the parameter during a parse operation, and the applicable currency or number decimal and group separators are the same, the parse operation assumes that the separator is a decimal separator rather than a group separator. For more information about separators, see , , , and .

  Converts the string representation of a number in a specified style and culture-specific format to its single-precision floating-point number equivalent.

  A single-precision floating-point number equivalent to the numeric value or symbol specified in .

  A string that contains a number to convert. A bitwise combination of enumeration values that indicates the style elements that can be present in . A typical value to specify is combined with . An object that supplies culture-specific formatting information about . 0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single Infinity

  The value of this constant is the result of dividing a positive number by zero.

  This constant is returned when the result of an operation is greater than .

  Use to determine whether a value evaluates to positive infinity.

  Represents positive infinity. This field is constant.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  true if the value of the current instance is not zero; otherwise, false.

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Byte ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Char `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  This conversion is not supported. No value is returned.

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  This conversion is not supported. No value is returned.

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Decimal ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Double ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to an .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to an .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to an .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.SByte ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to an .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  For a description of this member, see .

  The value of the current instance, unchanged.

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` `` To be added.

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the static (Shared in Visual Basic) method.

  For a description of this member, see .

  The value of the current instance, converted to .

  An object that supplies information about the format of the returned value.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.UInt16 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.UInt32 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.UInt64 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The method formats a value in the default ("G", or general) format of the current culture. If you want to specify a different format or culture, use the other overloads of the method, as follows:

  To use format

  For culture

  Use the overload

  Default ("G") format

  A specific culture

  A specific format

  Default (current) culture

  A specific format

  A specific culture

  The return value can be , , , or a string of the form:

  [sign]integral-digits[.[fractional-digits]][e[sign]exponential-digits]

  Optional elements are framed in square brackets ([ and ]). Elements that contain the term "digits" consist of a series of numeric characters ranging from 0 to 9. The following table lists each element:

  Element

  Description

  sign

  A negative sign or positive sign symbol.

  integral-digits

  A series of digits specifying the integral part of the number. Integral-digits can be absent if there are fractional-digits.

  '.'

  A culture-specific decimal point symbol.

  fractional-digits

  A series of digits specifying the fractional part of the number.

  'e'

  A lowercase character 'e', indicating exponential (scientific) notation.

  exponential-digits

  A series of digits specifying an exponent.

  Some examples of the return value are "100", "-123,456,789", "123.45e+6", "500", "3.1416", "600", "-0.123", and "-Infinity".

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.

  For more information about formatting, see Formatting Types.

  Converts the numeric value of this instance to its equivalent string representation.

  The string representation of the value of this instance.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  The method formats a value in the default ("G", or general) format of a specified culture. If you want to specify a different format or the current culture, use the other overloads of the method, as follows:

  To use format

  For culture

  Use the overload

  Default ("G") format

  Default (current) culture

  A specific format

  Default (current) culture

  A specific format

  A specific culture

  The return value can be , , , or a string of the form:

  [sign]integral-digits[.[fractional-digits]][e[sign]exponential-digits]

  Optional elements are framed in square brackets ([ and ]). Elements containing the term "digits" consist of a series of numeric characters ranging from 0 to 9. The following table lists each element.

  Element

  Description

  sign

  A negative sign or positive sign symbol.

  integral-digits

  A series of digits specifying the integral part of the number. Integral-digits can be absent if there are fractional-digits.

  '.'

  A culture-specific decimal point symbol.

  fractional-digits

  A series of digits specifying the fractional part of the number.

  'e'

  A lowercase character 'e', indicating exponential (scientific) notation.

  exponential-digits

  A series of digits specifying an exponent.

  Some examples of the return value are "100", "-123,456,789", "123.45e+6", "500", "3.1416", "600", "-0.123", and "-Infinity".

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.

  For more information about formatting, see Formatting Types.

  The parameter is an implementation whose method returns a object. Typically, is a object or a object. The parameter supplies culture-specific information used in formatting. If is null, the return value is formatted using the data for the current culture.

  To convert a value to its string representation using a specified culture and a specific format string, call the method.

  Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.

  The string representation of the value of this instance as specified by .

  An object that supplies culture-specific formatting information. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` is invalid.

  The following example shows the effects of various formats on the string returned by .

  `using System; class test { public static void Main() { float f = 1234.567f; Console.WriteLine(f); string[] fmts = {"C","E","e5","F","G","N","P","R"}; for (int i=0;i<fmts.Length;i++) Console.WriteLine("{0}: {1}", fmts[i],f.ToString(fmts[i])); } }`

  The output is

  1234.567

  C: $1,234.57

  E: 1.234567E+003

  e5: 1.23457e+003

  F: 1234.57

  G: 1234.567

  N: 1,234.57

  P: 123,456.70 %

  R: 1234.567

  The method formats a value in a specified format by using the conventions of the current culture. If you want to use the default ("G", or general) format or specify a different culture, use the other overloads of the method, as follows:

  To use format

  For culture

  Use the overload

  Default ("G") format

  Default (current) culture

  Default ("G") format

  A specific culture

  A specific format

  A specific culture

  The return value can be , , , or the string representation of the value of the current instance, as specified by .

  The parameter can be any valid standard numeric format specifier except for D and X, as well as any combination of custom numeric format specifiers. If format is null or an empty string, the return value is formatted with the general numeric format specifier ("G").

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.

  For more information about formatting, see Formatting Types.

  By default, the return value only contains 7 digits of precision although a maximum of 9 digits is maintained internally. If the value of this instance has greater than 7 digits, returns or instead of the expected number. If you require more precision, specify with the "G9" format specification, which always returns 9 digits of precision, or "R", which returns 7 digits if the number can be represented with that precision or 9 digits if the number can only be represented with maximum precision.

  Converts the numeric value of this instance to its equivalent string representation, using the specified format.

  The string representation of the value of this instance as specified by .

  A numeric format string. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` `` is invalid.

  The method formats a value in a specified format of a specified culture. If you want to use default format or culture settings, use the other overloads of the method, as follows:

  To use format

  For culture

  Use the overload

  Default ("G") format

  Default (current) culture

  Default ("G") format

  A specific culture

  A specific format

  Default (current) culture

  The return value can be , , , or the string representation of the value of the current instance, as specified by .

  The parameter can be any valid standard numeric format specifier except for D and X, as well as any combination of custom numeric format specifiers. If is null or an empty string, the return value for this instance is formatted with the general numeric format specifier ("G").

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.

  For more information about formatting, see Formatting Types.

  The parameter is an implementation whose method returns a object. Typically, is a object or a object. The parameter supplies culture-specific information used in formatting. If is null, the return value is formatted with the object for the current culture.

  By default, the return value only contains 7 digits of precision although a maximum of 9 digits is maintained internally. If the value of this instance has greater than 7 digits, returns or instead of the expected number. If you require more precision, specify with the "G9" format specification, which always returns 9 digits of precision, or "R", which returns 7 digits if the number can be represented with that precision or 9 digits if the number can only be represented with maximum precision.

  Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.

  The string representation of the value of this instance as specified by and .

  A numeric format string. An object that supplies culture-specific formatting information. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
0