CGFloat
@frozen struct CGFloat
@frozen struct CGFloat
import Foundation
protocol AdditiveArithmetic : Equatable
A type with values that support addition and subtraction.
protocol BinaryFloatingPoint : ExpressibleByFloatLiteral, FloatingPoint
A radix-2 (binary) floating-point type.
protocol BitwiseCopyable
protocol CVarArg
A type whose instances can be encoded, and appropriately passed, as elements of a C va_list
.
protocol Comparable : Equatable
A type that can be compared using the relational operators <
, <=
, >=
, and >
.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol CustomReflectable
A type that explicitly supplies its own mirror.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol ExpressibleByFloatLiteral
A type that can be initialized with a floating-point literal.
protocol ExpressibleByIntegerLiteral
A type that can be initialized with an integer literal.
protocol FloatingPoint : Hashable, SignedNumeric, Strideable where Self == Self.Magnitude
A floating-point numeric type.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol Numeric : AdditiveArithmetic, ExpressibleByIntegerLiteral
A type with values that support multiplication.
protocol Sendable
protocol SignedNumeric : Numeric
A numeric type with a negation operation.
protocol Strideable<Stride> : Comparable
A type representing continuous, one-dimensional values that can be offset and measured.
init()
init(_ value: CGFloat)
init(_ value: Double)
init(_ value: Float)
init(_ value: Int)
init(_ value: UInt)
Creates a new value, rounded to the closest possible representation.
init(_ value: Int8)
Creates a new value, rounded to the closest possible representation.
init(_ value: Int16)
Creates a new value, rounded to the closest possible representation.
init(_ value: Int32)
Creates a new value, rounded to the closest possible representation.
init(_ value: Int64)
Creates a new value, rounded to the closest possible representation.
init(_ value: UInt8)
Creates a new value, rounded to the closest possible representation.
init(_ value: UInt16)
Creates a new value, rounded to the closest possible representation.
init(_ value: UInt32)
Creates a new value, rounded to the closest possible representation.
init(_ value: UInt64)
Creates a new value, rounded to the closest possible representation.
init(bitPattern: UInt)
init?<T>(exactly source: T) where T : BinaryInteger
init(floatLiteral value: CGFloat.NativeType)
Create an instance initialized to value
.
init(from decoder: any Decoder) throws
init(integerLiteral value: Int)
Create an instance initialized to value
.
init(nan payload: CGFloat.RawSignificand, signaling: Bool)
init(sign: FloatingPointSign, exponent: Int, significand: CGFloat)
init(sign: FloatingPointSign, exponentBitPattern: UInt, significandBitPattern: UInt)
static var exponentBitCount: Int { get }
static var greatestFiniteMagnitude: CGFloat { get }
static var infinity: CGFloat { get }
static var leastNonzeroMagnitude: CGFloat { get }
static var leastNormalMagnitude: CGFloat { get }
static var nan: CGFloat { get }
static var pi: CGFloat { get }
static var signalingNaN: CGFloat { get }
static var significandBitCount: Int { get }
var binade: CGFloat { get }
var bitPattern: UInt { get }
var customMirror: Mirror { get }
Returns a mirror that reflects self
.
var description: String { get }
A textual representation of self
.
var exponent: Int { get }
var exponentBitPattern: UInt { get }
var floatingPointClass: FloatingPointClassification { get }
var hashValue: Int { get }
The hash value.
var isCanonical: Bool { get }
var isFinite: Bool { get }
var isInfinite: Bool { get }
var isNaN: Bool { get }
var isNormal: Bool { get }
var isSignalingNaN: Bool { get }
var isSubnormal: Bool { get }
var isZero: Bool { get }
var magnitude: CGFloat { get }
var native: CGFloat.NativeType
The native value.
var nextUp: CGFloat { get }
var sign: FloatingPointSign { get }
var significand: CGFloat { get }
var significandBitPattern: UInt { get }
var significandWidth: Int { get }
var ulp: CGFloat { get }
static func * (lhs: CGFloat, rhs: CGFloat) -> CGFloat
static func *= (lhs: inout CGFloat, rhs: CGFloat)
static func + (lhs: CGFloat, rhs: CGFloat) -> CGFloat
static func += (lhs: inout CGFloat, rhs: CGFloat)
static func - (lhs: CGFloat, rhs: CGFloat) -> CGFloat
static func -= (lhs: inout CGFloat, rhs: CGFloat)
static func / (lhs: CGFloat, rhs: CGFloat) -> CGFloat
static func /= (lhs: inout CGFloat, rhs: CGFloat)
mutating func addProduct(_ lhs: CGFloat, _ rhs: CGFloat)
func advanced(by amount: CGFloat) -> CGFloat
Returns a Self
x
such that self.distance(to: x)
approximates n
.
func distance(to other: CGFloat) -> CGFloat
Returns a stride x
such that self.advanced(by: x)
approximates other
.
func encode(to encoder: any Encoder) throws
mutating func formRemainder(dividingBy other: CGFloat)
mutating func formSquareRoot()
mutating func formTruncatingRemainder(dividingBy other: CGFloat)
func hash(into hasher: inout Hasher)
func isEqual(to other: CGFloat) -> Bool
func isLess(than other: CGFloat) -> Bool
func isLessThanOrEqualTo(_ other: CGFloat) -> Bool
mutating func negate()
mutating func round(_ rule: FloatingPointRoundingRule)
typealias Exponent = Int
typealias NativeType = Double
The native type used to store the CGFloat, which is Float on 32-bit architectures and Double on 64-bit architectures.
typealias RawSignificand = UInt
init<Source>(_ value: Source) where Source : BinaryFloatingPoint
Creates a new instance from the given value, rounded to the closest possible representation.
init<Source>(_ value: Source) where Source : BinaryInteger
Creates a new value, rounded to the closest possible representation.
init(_ value: String, format: FloatingPointFormatStyle<Self>.Percent, lenient: Bool = true) throws
init(_ value: String, format: FloatingPointFormatStyle<Self>.Currency, lenient: Bool = true) throws
init(_ value: String, format: FloatingPointFormatStyle<Self>, lenient: Bool = true) throws
Initialize an instance by parsing value
with a ParseStrategy
created with the given format
and the lenient
argument.
init<S>(_ value: S.ParseInput, strategy: S) throws where S : ParseStrategy, S.ParseOutput : BinaryFloatingPoint
Initialize an instance by parsing value
with the given strategy
.
init<S>(_ value: S.ParseInput, strategy: S) throws where Self == S.ParseOutput, S : ParseStrategy
init?<Source>(exactly value: Source) where Source : BinaryFloatingPoint
Creates a new instance from the given value, if it can be represented exactly.
init?<Source>(exactly value: Source) where Source : BinaryInteger
Creates a new value, if the given integer can be represented exactly.
init(signOf: Self, magnitudeOf: Self)
static var radix: Int { get }
static var ulpOfOne: Self { get }
static var zero: Self { get }
The zero value.
static func maximum(_ x: Self, _ y: Self) -> Self
static func maximumMagnitude(_ x: Self, _ y: Self) -> Self
static func minimum(_ x: Self, _ y: Self) -> Self
static func minimumMagnitude(_ x: Self, _ y: Self) -> Self
static func random(in range: ClosedRange<Self>) -> Self
Returns a random value within the specified range.
static func random(in range: Range<Self>) -> Self
Returns a random value within the specified range.
static func random<T>(in range: ClosedRange<Self>, using generator: inout T) -> Self where T : RandomNumberGenerator
Returns a random value within the specified range, using the given generator as a source for randomness.
static func random<T>(in range: Range<Self>, using generator: inout T) -> Self where T : RandomNumberGenerator
Returns a random value within the specified range, using the given generator as a source for randomness.
var nextDown: Self { get }
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func + (x: Self) -> Self
Returns the given number unchanged.
static func += (lhs: inout Self, rhs: Self)
static func - (operand: Self) -> Self
Returns the additive inverse of the specified value.
static func -= (lhs: inout Self, rhs: Self)
static func ... (minimum: Self) -> PartialRangeFrom<Self>
Returns a partial range extending upward from a lower bound.
static func ... (maximum: Self) -> PartialRangeThrough<Self>
Returns a partial range up to, and including, its upper bound.
static func ... (minimum: Self, maximum: Self) -> ClosedRange<Self>
Returns a closed range that contains both of its bounds.
static func ..< (maximum: Self) -> PartialRangeUpTo<Self>
Returns a partial range up to, but not including, its upper bound.
static func ..< (minimum: Self, maximum: Self) -> Range<Self>
Returns a half-open range that contains its lower bound but not its upper bound.
static func < (lhs: Self, rhs: Self) -> Bool
static func < (x: Self, y: Self) -> Bool
static func <= (lhs: Self, rhs: Self) -> Bool
static func <= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func == (lhs: Self, rhs: Self) -> Bool
static func == (x: Self, y: Self) -> Bool
static func > (lhs: Self, rhs: Self) -> Bool
static func > (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (lhs: Self, rhs: Self) -> Bool
static func >= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
func addingProduct(_ lhs: Self, _ rhs: Self) -> Self
func formatted() -> String
Format self
with FloatingPointFormatStyle()
.
func formatted<S>(_ format: S) -> S.FormatOutput where S : FormatStyle, S.FormatInput : BinaryFloatingPoint
Format self
with the given format. self
is first converted to S.FormatInput
type, then format with the given format.
func formatted<S>(_ format: S) -> S.FormatOutput where Self == S.FormatInput, S : FormatStyle
Format self
with the given format.
func isTotallyOrdered(belowOrEqualTo other: Self) -> Bool
mutating func negate()
Replaces this value with its additive inverse.
func remainder(dividingBy other: Self) -> Self
mutating func round()
func rounded() -> Self
func rounded(_ rule: FloatingPointRoundingRule) -> Self
func squareRoot() -> Self
func truncatingRemainder(dividingBy other: Self) -> Self