Home

CGFloat

CGFloat is a floating-point scalar type used in Apple graphics and UI frameworks to represent coordinates, sizes, and other geometric values. It underpins common geometric types such as CGPoint, CGSize, CGRect, and transforms like CGAffineTransform, providing a single numeric type for drawing and layout operations across the APIs.

The exact underlying type of CGFloat depends on the platform’s word size: on 32-bit environments it is

Because frameworks expect and return CGFloat values, code usually avoids mixing other floating-point types unnecessarily to

API and constants: Core Graphics provides platform-appropriate constants such as CGFLOAT_MIN and CGFLOAT_MAX, which reflect the

Summary: CGFloat offers a portable, architecture-aware floating type for core graphics and UI coordinates, enabling consistent

a
32-bit
float,
and
on
64-bit
environments
it
is
a
64-bit
double.
In
Objective-C,
CGFloat
is
traditionally
a
typedef
of
float
or
double
depending
on
architecture;
in
Swift,
it
is
a
platform-dependent
type
alias
to
Float
on
32-bit
and
to
Double
on
64-bit
platforms.
preserve
precision
and
minimize
conversions.
When
working
with
graphics
and
layout,
you
typically
use
CGPoint,
CGSize,
and
CGRect
values
composed
of
CGFloat
components.
On
devices
with
different
screen
scales,
a
point
corresponds
to
a
varying
number
of
pixels,
so
CGFloat
coordinates
often
represent
logical
units
rather
than
raw
pixels.
range
of
CGFloat
on
the
running
platform.
In
Swift,
CGFloat
integrates
with
the
language’s
FloatingPoint
protocol,
supporting
standard
numeric
operations
and
interoperability
with
Double
and
Float
as
needed.
APIs
across
32-bit
and
64-bit
Apple
platforms.