Structure

CGFloat

The basic type for floating-point scalar values in Core Graphics and related frameworks.

Overview

The size and precision of this type depend on the CPU architecture. When you build for a 64-bit CPU, the CGFloat type is a 64-bit, IEEE double-precision floating point type, equivalent to the Double type. When you build for a 32-bit CPU, the CGFloat type is a 32-bit, IEEE single-precision floating point type, equivalent to the Float type.

Topics

Type Aliases

typealias CGFloat.Exponent

An integer type that can represent any written exponent.

typealias CGFloat.NativeType

The native type used to store the CGFloat, which is Float on 32-bit architectures and Double on 64-bit architectures.

typealias CGFloat.RawSignificand

An unsigned integer type that can represent the significand of any value.

Initializers

init()

Create an instance initialized to zero.

init(NSNumber)Deprecated
init(Int)

value rounded to the closest representable Self.

init(Int64)

value rounded to the closest representable Self.

init(Float)

value rounded to the closest representable Self.

init(Int8)

value rounded to the closest representable Self.

init(UInt8)

value rounded to the closest representable Self.

init(Double)

value rounded to the closest representable Self.

init(Int16)

value rounded to the closest representable Self.

init(UInt32)

value rounded to the closest representable Self.

init(UInt)

value rounded to the closest representable Self.

init(UInt16)

value rounded to the closest representable Self.

init(Int32)

value rounded to the closest representable Self.

init(UInt64)

value rounded to the closest representable Self.

init(CGFloat)

Create an instance initialized to value.

init(Float80)

value rounded to the closest representable Self.

init(floatLiteral: CGFloat.NativeType)

Create an instance initialized to value.

init(floatLiteral: CGFloat.NativeType)

Create an instance initialized to value.

init(integerLiteral: Int)

Create an instance initialized to value.

init(sign: FloatingPointSign, exponent: Int, significand: CGFloat)

Initialize from sign, exponent, and significand.

init(sign: FloatingPointSign, exponentBitPattern: UInt, significandBitPattern: UInt)

Combines sign, exponent and significand bit patterns to produce a floating-point value.

Instance Properties

var binade: CGFloat

The least-magnitude member of the binade of self.

var customMirror: Mirror

A mirror that reflects the CGFloat instance.

var description: String

A textual representation of self.

var exponent: Int

The integer part of the base-r logarithm of the magnitude of self, where r is the radix (2 for binary, 10 for decimal). Implements the IEEE 754 logB operation.

var exponentBitPattern: UInt

The raw encoding of the exponent field of the floating-point value.

var floatingPointClass: FloatingPointClassification

The IEEE 754 “class” of this type.

var hashValue: Int

The hash value.

var isCanonical: Bool

True if and only if self is canonical.

var isFinite: Bool

true iff self is zero, subnormal, or normal (not infinity or NaN).

var isInfinite: Bool

true iff self is infinity.

var isNaN: Bool

true iff self is NaN.

var isNormal: Bool

true iff self is normal (not zero, subnormal, infinity, or NaN).

var isSignalingNaN: Bool

True if and only if self is a signaling NaN.

var isSubnormal: Bool

true iff self is subnormal.

var isZero: Bool

true iff self is +0.0 or -0.0.

var nextUp: CGFloat

The least representable value that compares greater than self.

var sign: FloatingPointSign

minus if the sign bit of self is set, and plus otherwise. Implements the IEEE 754 signbit operation.

var significand: CGFloat

The significant digits, or mantissa, of the floating-point number.

var significandBitPattern: UInt

The raw encoding of the significand field of the floating-point value.

var significandWidth: Int

The number of bits required to represent significand.

var ulp: CGFloat

The unit in the last place of self.

Type Properties

static var exponentBitCount: Int

The number of bits used to represent the exponent.

static var infinity: CGFloat

The positive infinity.

static var leastNormalMagnitude: CGFloat

The least positive normal number.

static var pi: CGFloat

The mathematical constant pi = 3.14159…

static var signalingNaN: CGFloat

A signaling NaN (not-a-number).

static var significandBitCount: Int

For fixed-width floating-point types, this is the number of fractional significand bits.

Instance Methods

See Also

Geometric Data Types

struct CGPoint

A structure that contains a point in a two-dimensional coordinate system.

struct CGSize

A structure that contains width and height values.

struct CGRect

A structure that contains the location and dimensions of a rectangle.

struct CGVector

A structure that contains a two-dimensional vector.

struct CGAffineTransform

An affine transformation matrix for use in drawing 2D graphics.