Skip to content
CShift0.32

float

Struct · built-in type

struct float : IComparable<float>, IEquatable<float>, IHashable

A 32-bit floating point number (IEEE 754 single precision); float32 is the same type.

Floating point arithmetic is not checked: it gives infinity or NaN instead of a panic.

Name Description
MinValue The smallest (most negative) finite value.
MaxValue The largest finite value.
Epsilon The difference between 1 and the next larger value.
NaN “Not a number”, e.g. the result of 0.0 / 0.0; it is not equal to anything, not even to itself.
PositiveInfinity Positive infinity, e.g. the result of 1.0 / 0.0.
NegativeInfinity Negative infinity.
static float MinValue

The smallest (most negative) finite value.

static float MaxValue

The largest finite value.

static float Epsilon

The difference between 1 and the next larger value.

static float NaN

“Not a number”, e.g. the result of 0.0 / 0.0; it is not equal to anything, not even to itself.

static float PositiveInfinity

Positive infinity, e.g. the result of 1.0 / 0.0.

static float NegativeInfinity

Negative infinity.

Name Description
ToString The number as text, with as many digits as needed to read it back exactly: 0.1.ToString() is "0.1".
Equals Whether the numbers are equal (also a == b; NaN is not equal to NaN).
CompareTo Compares the numbers: -1, 0 or 1.
GetHashCode A hash code of the number, for Dictionary keys.
string ToString()

The number as text, with as many digits as needed to read it back exactly: 0.1.ToString() is "0.1".

string ToString(string format)

The number in a number format: 3.14159.ToString("F2") is "3.14" (see NumberFormat).

Parameters

  • format: F, N, E, P or G, optionally followed by up to two digits.
bool Equals(float other)

Whether the numbers are equal (also a == b; NaN is not equal to NaN).

int CompareTo(float other)

Compares the numbers: -1, 0 or 1.

int GetHashCode()

A hash code of the number, for Dictionary keys.