System.Single Struct

Struct System

Summary

Represents a single-precision floating-point number.

Description

The System.Single structure represents a 32-bit floating-point number.

It is used to represent real numbers with a wide range and precision, suitable for scientific and engineering calculations where a balance between range and memory usage is required.

The Single type conforms to the IEEE 754 standard for floating-point arithmetic.

Syntax

[StructLayout(LayoutKind.Sequential)] [Serializable] public struct Single : IConvertible, IComparable, IFormattable

Fields

MaxValue

public const float MaxValue

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

MinValue

public const float MinValue

Represents the smallest possible positive, normalized value of a Single. This field is constant.

Epsilon

public const float Epsilon

The difference between 1.0 and the next greater Single number. This field is constant.

NaN

public const float NaN

Represents a Not-a-Number (NaN) value. This field is constant.

NegativeInfinity

public const float NegativeInfinity

Represents negative infinity. This field is constant.

PositiveInfinity

public const float PositiveInfinity

Represents positive infinity. This field is constant.

Methods

CompareTo

public int CompareTo(object value)

Compares the current instance to another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

Equals

public bool Equals(float value)

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

Parse

public static float Parse(string s)

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


string numberString = "123.45";
float result = float.Parse(numberString); // result is 123.45f
                        

ToString

public override string ToString()

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

See Also