One Logo Pool Ball
CoreFoundation · IOS API REFERENCE

CGFloat

struct · iOS 2.0+ · SDK 27.1

@frozen struct CGFloat

Members (56)

method · iOS 2.0+

addProduct

TypeScript
addProduct(lhs: number, rhs: number): void
Swift declaration
mutating func addProduct(_ lhs: CGFloat, _ rhs: CGFloat)

Adds the product of the two given values to this value in place, computed without intermediate rounding. - Parameters: - lhs: One of the values to multiply before adding to this value. - rhs: The other value to multiply.

init · iOS 2.0+

init

TypeScript
static initBitPattern(bitPattern: number): number
Swift declaration
init(bitPattern: UInt)
get · iOS 2.0+

bitPattern

TypeScript
get bitPattern(): number
Swift declaration
var bitPattern: UInt { get }
get · iOS 2.0+

isInfinite

TypeScript
get isInfinite(): boolean
Swift declaration
var isInfinite: Bool { get }

A Boolean value indicating whether the instance is infinite. For NaN, both `isFinite` and `isInfinite` are false.

get · iOS 2.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of `self`.

get · iOS 2.0+

isCanonical

TypeScript
get isCanonical(): boolean
Swift declaration
var isCanonical: Bool { get }

A Boolean value indicating whether the instance's representation is in its canonical form. The [IEEE 754 specification][spec] defines a *canonical*, or preferred, encoding of a floating-point value. On platforms that fully support IEEE 754, every `Float` or `Double` value is canonical, but non-canonical values can exist on other platforms or for other types. Some examples: - On platforms that flush subnormal numbers to zero (such as armv7 with the default floating-point environment), Swift interprets subnormal `Float` and `Double` values as non-canonical zeros. (In Swift 5.1 and earlier, `isCanonical` is `true` for these values, which is the incorrect value.) - On i386 and x86_64, `Float80` has a number of non-canonical encodings. "Pseudo-NaNs", "pseudo-infinities", and "unnormals" are interpreted as non-canonical NaN encodings. "Pseudo-denormals" are interpreted as non-canonical encodings of subnormal values. - Decimal floating-point types admit a large number of non-canonical encodings. Consult the IEEE 754 standard for additional details. [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933

get · iOS 2.0+

isSubnormal

TypeScript
get isSubnormal(): boolean
Swift declaration
var isSubnormal: Bool { get }

A Boolean value indicating whether the instance is subnormal. A *subnormal* value is a nonzero number that has a lesser magnitude than the smallest normal number. Subnormal values don't use the full precision available to values of a type. Zero is neither a normal nor a subnormal number. Subnormal numbers are often called *denormal* or *denormalized*---these are different names for the same concept.

get · iOS 2.0+

significand

TypeScript
get significand(): number
Swift declaration
var significand: CGFloat { get }

The significand of the floating-point value. The magnitude of a floating-point value `x` of type `F` can be calculated by using the following formula, where `**` is exponentiation: x.significand * (F.radix ** x.exponent) In the next example, `y` has a value of `21.5`, which is encoded as `1.34375 * 2 ** 4`. The significand of `y` is therefore 1.34375. let y: Double = 21.5 // y.significand == 1.34375 // y.exponent == 4 // Double.radix == 2 If a type's radix is 2, then for finite nonzero numbers, the significand is in the range `1.0 ..< 2.0`. For other values of `x`, `x.significand` is defined as follows: - If `x` is zero, then `x.significand` is 0.0. - If `x` is infinite, then `x.significand` is infinity. - If `x` is NaN, then `x.significand` is NaN. - Note: The significand is frequently also called the *mantissa*, but significand is the preferred terminology in the [IEEE 754 specification][spec], to allay confusion with the use of mantissa for the fractional part of a logarithm. [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933

get · iOS 2.0+

customMirror

TypeScript
get customMirror(): SDKHandle
Swift declaration
var customMirror: Mirror { get }

Returns a mirror that reflects `self`.

init · iOS 2.0+

init

TypeScript
static initFloatLiteral(value: number): number
Swift declaration
init(floatLiteral value: CGFloat.NativeType)

Create an instance initialized to `value`.

get · iOS 2.0+

signalingNaN

TypeScript
static get signalingNaN(): number
Swift declaration
static var signalingNaN: CGFloat { get }

A signaling NaN ("not a number"). The default IEEE 754 behavior of operations involving a signaling NaN is to raise the Invalid flag in the floating-point environment and return a quiet NaN. Operations on types conforming to the `FloatingPoint` protocol should support this behavior, but they might also support other options. For example, it would be reasonable to implement alternative operations in which operating on a signaling NaN triggers a runtime error or results in a diagnostic for debugging purposes. Types that implement alternative behaviors for a signaling NaN must document the departure. Other than these signaling operations, a signaling NaN behaves in the same manner as a quiet NaN.

method · iOS 2.0+

formRemainder

TypeScript
formRemainder(other: number): void
Swift declaration
mutating func formRemainder(dividingBy other: CGFloat)

Replaces this value with the remainder of itself divided by the given value. For two finite values `x` and `y`, the remainder `r` of dividing `x` by `y` satisfies `x == y * q + r`, where `q` is the integer nearest to `x / y`. If `x / y` is exactly halfway between two integers, `q` is chosen to be even. Note that `q` is *not* `x / y` computed in floating-point arithmetic, and that `q` may not be representable in any available integer type. The following example calculates the remainder of dividing 8.625 by 0.75: var x = 8.625 print(x / 0.75) // Prints "11.5" let q = (x / 0.75).rounded(.toNearestOrEven) // q == 12.0 x.formRemainder(dividingBy: 0.75) // x == -0.375 let x1 = 0.75 * q + x // x1 == 8.625 If this value and `other` are finite numbers, the remainder is in the closed range `-abs(other / 2)...abs(other / 2)`. The `formRemainder(dividingBy:)` method is always exact. - Parameter other: The value to use when dividing this value.

method · iOS 2.0+

formSquareRoot

TypeScript
formSquareRoot(): void
Swift declaration
mutating func formSquareRoot()

Replaces this value with its square root, rounded to a representable value.

init · iOS 2.0+

init

TypeScript
static initIntegerLiteral(value: number): number
Swift declaration
init(integerLiteral value: Int)

Create an instance initialized to `value`.

get · iOS 2.0+

isSignalingNaN

TypeScript
get isSignalingNaN(): boolean
Swift declaration
var isSignalingNaN: Bool { get }

A Boolean value indicating whether the instance is a signaling NaN. Signaling NaNs typically raise the Invalid flag when used in general computing operations.

get · iOS 2.0+

exponentBitCount

TypeScript
static get exponentBitCount(): number
Swift declaration
static var exponentBitCount: Int { get }

The number of bits used to represent the type's exponent. A binary floating-point type's `exponentBitCount` imposes a limit on the range of the exponent for normal, finite values. The *exponent bias* of a type `F` can be calculated as the following, where `**` is exponentiation: let bias = 2 ** (F.exponentBitCount - 1) - 1 The least normal exponent for values of the type `F` is `1 - bias`, and the largest finite exponent is `bias`. An all-zeros exponent is reserved for subnormals and zeros, and an all-ones exponent is reserved for infinity and NaN. For example, the `Float` type has an `exponentBitCount` of 8, which gives an exponent bias of `127` by the calculation above. let bias = 2 ** (Float.exponentBitCount - 1) - 1 // bias == 127 print(Float.greatestFiniteMagnitude.exponent) // Prints "127" print(Float.leastNormalMagnitude.exponent) // Prints "-126"

get · iOS 2.0+

significandWidth

TypeScript
get significandWidth(): number
Swift declaration
var significandWidth: Int { get }

The number of bits required to represent the value's significand. If this value is a finite nonzero number, `significandWidth` is the number of fractional bits required to represent the value of `significand`; otherwise, `significandWidth` is -1. The value of `significandWidth` is always -1 or between zero and `significandBitCount`. For example: - For any representable power of two, `significandWidth` is zero, because `significand` is `1.0`. - If `x` is 10, `x.significand` is `1.01` in binary, so `x.significandWidth` is 2. - If `x` is Float.pi, `x.significand` is `1.10010010000111111011011` in binary, and `x.significandWidth` is 23.

get · iOS 2.0+

exponentBitPattern

TypeScript
get exponentBitPattern(): number
Swift declaration
var exponentBitPattern: UInt { get }

The raw encoding of the value's exponent field. This value is unadjusted by the type's exponent bias.

get · iOS 2.0+

floatingPointClass

TypeScript
get floatingPointClass(): SDKHandle
Swift declaration
var floatingPointClass: FloatingPointClassification { get }

The classification of this value. A value's `floatingPointClass` property describes its "class" as described by the [IEEE 754 specification][spec]. [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933

method · iOS 2.0+

isLessThanOrEqualTo

TypeScript
isLessThanOrEqualTo(other: number): boolean
Swift declaration
func isLessThanOrEqualTo(_ other: CGFloat) -> Bool

Returns a Boolean value indicating whether this instance is less than or equal to the given value. This method serves as the basis for the less-than-or-equal-to operator (`<=`) for floating-point values. Some special cases apply: - Because NaN is incomparable with any value, this method returns `false` when called on NaN or when NaN is passed as `other`. - `-infinity` compares less than or equal to all values except NaN. - Every value except NaN compares less than or equal to `+infinity`. The following example shows the behavior of the `isLessThanOrEqualTo(_:)` method with different kinds of values: let x = 15.0 x.isLessThanOrEqualTo(20.0) // true x.isLessThanOrEqualTo(.nan) // false Double.nan.isLessThanOrEqualTo(x) // false The `isLessThanOrEqualTo(_:)` method implements the less-than-or-equal predicate defined by the [IEEE 754 specification][spec]. [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933 - Parameter other: The value to compare with this value. - Returns: `true` if `other` is greater than this value; otherwise, `false`. If either this value or `other` is NaN, the result of this method is `false`.

get · iOS 2.0+

significandBitCount

TypeScript
static get significandBitCount(): number
Swift declaration
static var significandBitCount: Int { get }

The available number of fractional significand bits. For fixed-width floating-point types, this is the actual number of fractional significand bits. For extensible floating-point types, `significandBitCount` should be the maximum allowed significand width (without counting any leading integral bit of the significand). If there is no upper limit, then `significandBitCount` should be `Int.max`. Note that `Float80.significandBitCount` is 63, even though 64 bits are used to store the significand in the memory representation of a `Float80` (unlike other floating-point types, `Float80` explicitly stores the leading integral significand bit, but the `BinaryFloatingPoint` APIs provide an abstraction so that users don't need to be aware of this detail).

get · iOS 2.0+

leastNormalMagnitude

TypeScript
static get leastNormalMagnitude(): number
Swift declaration
static var leastNormalMagnitude: CGFloat { get }

The least positive normal number. This value compares less than or equal to all positive normal numbers. There may be smaller positive numbers, but they are *subnormal*, meaning that they are represented with less precision than normal numbers. This value corresponds to type-specific C macros such as `FLT_MIN` and `DBL_MIN`. The naming of those macros is slightly misleading, because subnormals, zeros, and negative numbers are smaller than this value.

get · iOS 2.0+

leastNonzeroMagnitude

TypeScript
static get leastNonzeroMagnitude(): number
Swift declaration
static var leastNonzeroMagnitude: CGFloat { get }

The least positive number. This value compares less than or equal to all positive numbers, but greater than zero. If the type supports subnormal values, `leastNonzeroMagnitude` is smaller than `leastNormalMagnitude`; otherwise they are equal.

get · iOS 2.0+

significandBitPattern

TypeScript
get significandBitPattern(): number
Swift declaration
var significandBitPattern: UInt { get }

The raw encoding of the value's significand field. The `significandBitPattern` property does not include the leading integral bit of the significand, even for types like `Float80` that store it explicitly.

method · iOS 2.0+

formTruncatingRemainder

TypeScript
formTruncatingRemainder(other: number): void
Swift declaration
mutating func formTruncatingRemainder(dividingBy other: CGFloat)

Replaces this value with the remainder of itself divided by the given value using truncating division. Performing truncating division with floating-point values results in a truncated integer quotient and a remainder. For values `x` and `y` and their truncated integer quotient `q`, the remainder `r` satisfies `x == y * q + r`. The following example calculates the truncating remainder of dividing 8.625 by 0.75: var x = 8.625 print(x / 0.75) // Prints "11.5" let q = (x / 0.75).rounded(.towardZero) // q == 11.0 x.formTruncatingRemainder(dividingBy: 0.75) // x == 0.375 let x1 = 0.75 * q + x // x1 == 8.625 If this value and `other` are both finite numbers, the truncating remainder has the same sign as this value and is strictly smaller in magnitude than `other`. The `formTruncatingRemainder(dividingBy:)` method is always exact. - Parameter other: The value to use when dividing this value.

get · iOS 2.0+

greatestFiniteMagnitude

TypeScript
static get greatestFiniteMagnitude(): number
Swift declaration
static var greatestFiniteMagnitude: CGFloat { get }

The greatest finite number representable by this type. This value compares greater than or equal to all finite numbers, but less than `infinity`. This value corresponds to type-specific C macros such as `FLT_MAX` and `DBL_MAX`. The naming of those macros is slightly misleading, because `infinity` is greater than this value.

get · iOS 2.0+

pi

TypeScript
static get pi(): number
Swift declaration
static var pi: CGFloat { get }

The mathematical constant pi (π), approximately equal to 3.14159. When measuring an angle in radians, π is equivalent to a half-turn. This value is 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"

init · iOS 2.0+

init

TypeScript
static initNanSignaling(payload: number, signaling: boolean): number
Swift declaration
init(nan payload: CGFloat.RawSignificand, signaling: Bool)
get · iOS 2.0+

nan

TypeScript
static get nan(): number
Swift declaration
static var nan: CGFloat { get }

A quiet NaN ("not a number"). A NaN compares not equal, not greater than, and not less than every value, including itself. Passing a NaN to an operation generally results in NaN. let x = 1.21 // x > Double.nan == false // x < Double.nan == false // x == Double.nan == false Because a NaN always compares not equal to itself, to test whether a floating-point value is NaN, use its `isNaN` property instead of the equal-to operator (`==`). In the following example, `y` is NaN. let y = x + Double.nan print(y == Double.nan) // Prints "false" print(y.isNaN) // Prints "true"

get · iOS 2.0+

ulp

TypeScript
get ulp(): number
Swift declaration
var ulp: CGFloat { get }

The unit in the last place of this value. This is the unit of the least significant digit in this value's significand. For most numbers `x`, this is the difference between `x` and the next greater (in magnitude) representable number. There are some edge cases to be aware of: - If `x` is not a finite number, then `x.ulp` is NaN. - If `x` is very small in magnitude, then `x.ulp` may be a subnormal number. If a type does not support subnormals, `x.ulp` may be rounded to zero. - `greatestFiniteMagnitude.ulp` is a finite number, even though the next greater representable value is `infinity`. See also the `ulpOfOne` static property.

init · iOS 2.0+

init

TypeScript
static initSignExponentBitPatternSignificandBitPattern(sign: SDKHandle, exponentBitPattern: number, significandBitPattern: number): number
Swift declaration
init(sign: FloatingPointSign, exponentBitPattern: UInt, significandBitPattern: UInt)

Creates a new instance from the specified sign and bit patterns. The values passed as `exponentBitPattern` and `significandBitPattern` are interpreted in the binary interchange format defined by the [IEEE 754 specification][spec]. [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933 - Parameters: - sign: The sign of the new value. - exponentBitPattern: The bit pattern to use for the exponent field of the new value. - significandBitPattern: The bit pattern to use for the significand field of the new value.

init · iOS 2.0+

init

TypeScript
static initSignExponentSignificand(sign: SDKHandle, exponent: number, significand: number): number
Swift declaration
init(sign: FloatingPointSign, exponent: Int, significand: CGFloat)

Creates a new value from the given sign, exponent, and significand. The following example uses this initializer to create a new `Double` instance. `Double` is a binary floating-point type that has a radix of `2`. let x = Double(sign: .plus, exponent: -2, significand: 1.5) // x == 0.375 This initializer is equivalent to the following calculation, where `**` is exponentiation, computed as if by a single, correctly rounded, floating-point operation: let sign: FloatingPointSign = .plus let exponent = -2 let significand = 1.5 let y = (sign == .minus ? -1 : 1) * significand * Double.radix ** exponent // y == 0.375 As with any basic operation, if this value is outside the representable range of the type, overflow or underflow occurs, and zero, a subnormal value, or infinity may result. In addition, there are two other edge cases: - If the value you pass to `significand` is zero or infinite, the result is zero or infinite, regardless of the value of `exponent`. - If the value you pass to `significand` is NaN, the result is NaN. For any floating-point value `x` of type `F`, the result of the following is equal to `x`, with the distinction that the result is canonicalized if `x` is in a noncanonical encoding: let x0 = F(sign: x.sign, exponent: x.exponent, significand: x.significand) This initializer implements the `scaleB` operation defined by the [IEEE 754 specification][spec]. [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933 - Parameters: - sign: The sign to use for the new value. - exponent: The new value's exponent. - significand: The new value's significand.

get · iOS 2.0+

sign

TypeScript
get sign(): SDKHandle
Swift declaration
var sign: FloatingPointSign { get }

The sign of the floating-point value. The `sign` property is `.minus` if the value's signbit is set, and `.plus` otherwise. For example: let x = -33.375 // x.sign == .minus Don't use this property to check whether a floating point value is negative. For a value `x`, the comparison `x.sign == .minus` is not necessarily the same as `x < 0`. In particular, `x.sign == .minus` if `x` is -0, and while `x < 0` is always `false` if `x` is NaN, `x.sign` could be either `.plus` or `.minus`.

get · iOS 2.0+

isNaN

TypeScript
get isNaN(): boolean
Swift declaration
var isNaN: Bool { get }

A Boolean value indicating whether the instance is NaN ("not a number"). Because NaN is not equal to any value, including NaN, use this property instead of the equal-to operator (`==`) or not-equal-to operator (`!=`) to test whether a value is or is not NaN. For example: let x = 0.0 let y = x * .infinity // y is a NaN // Comparing with the equal-to operator never returns 'true' print(x == Double.nan) // Prints "false" print(y == Double.nan) // Prints "false" // Test with the 'isNaN' property instead print(x.isNaN) // Prints "false" print(y.isNaN) // Prints "true" This property is `true` for both quiet and signaling NaNs.

method · iOS 2.0+

round

TypeScript
round(rule: SDKHandle): void
Swift declaration
mutating func round(_ rule: FloatingPointRoundingRule)

Rounds the value to an integral value using the specified rounding rule. The following example rounds a value using four different rounding rules: // Equivalent to the C 'round' function: var w = 6.5 w.round(.toNearestOrAwayFromZero) // w == 7.0 // Equivalent to the C 'trunc' function: var x = 6.5 x.round(.towardZero) // x == 6.0 // Equivalent to the C 'ceil' function: var y = 6.5 y.round(.up) // y == 7.0 // Equivalent to the C 'floor' function: var z = 6.5 z.round(.down) // z == 6.0 For more information about the available rounding rules, see the `FloatingPointRoundingRule` enumeration. To round a value using the default "schoolbook rounding" of `.toNearestOrAwayFromZero`, you can use the shorter `round()` method instead. var w1 = 6.5 w1.round() // w1 == 7.0 - Parameter rule: The rounding rule to use.

get · iOS 2.0+

binade

TypeScript
get binade(): number
Swift declaration
var binade: CGFloat { get }

The floating-point value with the same sign and exponent as this value, but with a significand of 1.0. A *binade* is a set of binary floating-point values that all have the same sign and exponent. The `binade` property is a member of the same binade as this value, but with a unit significand. In this example, `x` has a value of `21.5`, which is stored as `1.34375 * 2**4`, where `**` is exponentiation. Therefore, `x.binade` is equal to `1.0 * 2**4`, or `16.0`. let x = 21.5 // x.significand == 1.34375 // x.exponent == 4 let y = x.binade // y == 16.0 // y.significand == 1.0 // y.exponent == 4

method · iOS 2.0+

isLess

TypeScript
isLess(other: number): boolean
Swift declaration
func isLess(than other: CGFloat) -> Bool

Returns a Boolean value indicating whether this instance is less than the given value. This method serves as the basis for the less-than operator (`<`) for floating-point values. Some special cases apply: - Because NaN compares not less than nor greater than any value, this method returns `false` when called on NaN or when NaN is passed as `other`. - `-infinity` compares less than all values except for itself and NaN. - Every value except for NaN and `+infinity` compares less than `+infinity`. The following example shows the behavior of the `isLess(than:)` method with different kinds of values: let x = 15.0 x.isLess(than: 20.0) // true x.isLess(than: .nan) // false Double.nan.isLess(than: x) // false The `isLess(than:)` method implements the less-than predicate defined by the [IEEE 754 specification][spec]. [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933 - Parameter other: The value to compare with this value. - Returns: `true` if this value is less than `other`; otherwise, `false`. If either this value or `other` is NaN, the result of this method is `false`.

get · iOS 2.0+

isZero

TypeScript
get isZero(): boolean
Swift declaration
var isZero: Bool { get }

A Boolean value indicating whether the instance is equal to zero. The `isZero` property of a value `x` is `true` when `x` represents either `-0.0` or `+0.0`. `x.isZero` is equivalent to the following comparison: `x == 0.0`. let x = -0.0 x.isZero // true x == 0.0 // true

get · iOS 2.0+

native

TypeScript
get native(): number
Swift declaration
var native: CGFloat.NativeType

The native value.

set · iOS 2.0+

native

TypeScript
set native(value: number)
Swift declaration
var native: CGFloat.NativeType

The native value.

method · iOS 2.0+

negate

TypeScript
negate(): void
Swift declaration
mutating func negate()

Replaces this value with its additive inverse. The following example uses the `negate()` method to negate the value of an integer `x`: var x = 21 x.negate() // x == -21 The resulting value must be representable within the value's type. In particular, negating a signed, fixed-width integer type's minimum results in a value that cannot be represented. var y = Int8.min y.negate() // Overflow error

get · iOS 2.0+

nextUp

TypeScript
get nextUp(): number
Swift declaration
var nextUp: CGFloat { get }

The least representable value that compares greater than this value. For any finite value `x`, `x.nextUp` is greater than `x`. For `nan` or `infinity`, `x.nextUp` is `x` itself. The following special cases also apply: - If `x` is `-infinity`, then `x.nextUp` is `-greatestFiniteMagnitude`. - If `x` is `-leastNonzeroMagnitude`, then `x.nextUp` is `-0.0`. - If `x` is zero, then `x.nextUp` is `leastNonzeroMagnitude`. - If `x` is `greatestFiniteMagnitude`, then `x.nextUp` is `infinity`.

init · iOS 2.0+

init

TypeScript
static initExactly(source: number): (number) | null
Swift declaration
init?<T>(exactly source: T) where T : BinaryInteger

Creates a new instance from the given integer, if it can be represented exactly. If the value passed as `source` is not representable exactly, the result is `nil`. In the following example, the constant `x` is successfully created from a value of `100`, while the attempt to initialize the constant `y` from `1_000` fails because the `Int8` type can represent `127` at maximum: let x = Int8(exactly: 100) // x == Optional(100) let y = Int8(exactly: 1_000) // y == nil - Parameter source: A value to convert to this type.

method · iOS 2.0+

isEqual

TypeScript
isEqual(other: number): boolean
Swift declaration
func isEqual(to other: CGFloat) -> Bool

Returns a Boolean value indicating whether this instance is equal to the given value. This method serves as the basis for the equal-to operator (`==`) for floating-point values. When comparing two values with this method, `-0` is equal to `+0`. NaN is not equal to any value, including itself. For example: let x = 15.0 x.isEqual(to: 15.0) // true x.isEqual(to: .nan) // false Double.nan.isEqual(to: .nan) // false The `isEqual(to:)` method implements the equality predicate defined by the [IEEE 754 specification][spec]. [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933 - Parameter other: The value to compare with this value. - Returns: `true` if `other` has the same value as this instance; otherwise, `false`. If either this value or `other` is NaN, the result of this method is `false`.

method · iOS 2.0+

advanced

TypeScript
advanced(amount: number): number
Swift declaration
func advanced(by amount: CGFloat) -> CGFloat

Returns a `Self` `x` such that `self.distance(to: x)` approximates `n`. - Complexity: O(1).

method · iOS 2.0+

distance

TypeScript
distance(other: number): number
Swift declaration
func distance(to other: CGFloat) -> CGFloat

Returns a stride `x` such that `self.advanced(by: x)` approximates `other`. - Complexity: O(1).

get · iOS 2.0+

exponent

TypeScript
get exponent(): number
Swift declaration
var exponent: Int { get }

The exponent of the floating-point value. The *exponent* of a floating-point value is the integer part of the logarithm of the value's magnitude. For a value `x` of a floating-point type `F`, the magnitude can be calculated as the following, where `**` is exponentiation: x.significand * (F.radix ** x.exponent) In the next example, `y` has a value of `21.5`, which is encoded as `1.34375 * 2 ** 4`. The significand of `y` is therefore 1.34375. let y: Double = 21.5 // y.significand == 1.34375 // y.exponent == 4 // Double.radix == 2 The `exponent` property has the following edge cases: - If `x` is zero, then `x.exponent` is `Int.min`. - If `x` is +/-infinity or NaN, then `x.exponent` is `Int.max` This property implements the `logB` operation defined by the [IEEE 754 specification][spec]. [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933

get · iOS 2.0+

infinity

TypeScript
static get infinity(): number
Swift declaration
static var infinity: CGFloat { get }

Positive infinity. Infinity compares greater than all finite numbers and equal to other infinite values. let x = Double.greatestFiniteMagnitude let y = x * 2 // y == Double.infinity // y > x

get · iOS 2.0+

isFinite

TypeScript
get isFinite(): boolean
Swift declaration
var isFinite: Bool { get }

A Boolean value indicating whether this instance is finite. All values other than NaN and infinity are considered finite, whether normal or subnormal. For NaN, both `isFinite` and `isInfinite` are false.

get · iOS 2.0+

isNormal

TypeScript
get isNormal(): boolean
Swift declaration
var isNormal: Bool { get }

A Boolean value indicating whether this instance is normal. A *normal* value is a finite number that uses the full precision available to values of a type. Zero is neither a normal nor a subnormal number.

get · iOS 2.0+

magnitude

TypeScript
get magnitude(): number
Swift declaration
var magnitude: CGFloat { get }

The magnitude of this value. For any numeric value `x`, `x.magnitude` is the absolute value of `x`. You can use the `magnitude` property in operations that are simpler to implement in terms of unsigned values, such as printing the value of an integer, which is just printing a '-' character in front of an absolute value. let x = -200 // x.magnitude == 200 The global `abs(_:)` function provides more familiar syntax when you need to find an absolute value. In addition, because `abs(_:)` always returns a value of the same type, even in a generic context, using the function instead of the `magnitude` property is encouraged.

init · iOS 2.0+

init

TypeScript
static init(): number
Swift declaration
init()
init · iOS 2.0+

init

TypeScript
static init71315(value: number): number
Swift declaration
init(_ value: CGFloat)
init · iOS 2.0+

init

TypeScript
static init93076(value: number): number
Swift declaration
init(_ value: Double)

Creates a new instance from the given value, rounded to the closest possible representation. - Parameter value: A floating-point value to be converted.

init · iOS 2.0+

init

TypeScript
static init57126(value: number): number
Swift declaration
init(_ value: Float)

Creates a new instance from the given value, rounded to the closest possible representation. - Parameter value: A floating-point value to be converted.

init · iOS 2.0+

init

TypeScript
static init91565(source: number): number
Swift declaration
init<T>(_ source: T) where T : BinaryInteger

Creates a new value, rounded to the closest possible representation. If two representable values are equally close, the result is the value with more trailing zeros in its significand bit pattern. - Parameter value: The integer to convert to a floating-point value.

Skipped declarations

No declarations were skipped in this snapshot.

All CoreFoundation types →