Type Property

pi

The mathematical constant pi.

Declaration

static var pi: Double { get }

Discussion

This value should be rounded toward zero to keep user computations with angles from inadvertently ending up in the wrong quadrant. A type that conforms to the FloatingPoint protocol provides the value for pi at its best possible precision.

print(Double.pi)
// Prints "3.14159265358979"

Relationships

From Protocol

See Also

Accessing Numeric Constants

static var infinity: Double

Positive infinity.

static var greatestFiniteMagnitude: Double

The greatest finite number representable by this type.

static var nan: Double

A quiet NaN (“not a number”).

static var signalingNaN: Double

A signaling NaN (“not a number”).

static var ulpOfOne: Double

The unit in the last place of 1.0.

static var leastNormalMagnitude: Double

The least positive normal number.