Type Property

ulpOfOne

The unit in the last place of 1.0.

Required. Default implementation provided.

Declaration

static var ulpOfOne: Self { get }

Discussion

The positive difference between 1.0 and the next greater representable number. ulpOfOne corresponds to the value represented by the C macros FLT_EPSILON, DBL_EPSILON, etc, and is sometimes called epsilon or machine epsilon. Swift deliberately avoids using the term “epsilon” because:

  • Historically “epsilon” has been used to refer to several different concepts in different languages, leading to confusion and bugs.

  • The name “epsilon” suggests that this quantity is a good tolerance to choose for approximate comparisons, but it is almost always unsuitable for that purpose.

See also the ulp member property.

Default Implementations

FloatingPoint Implementations

static var ulpOfOne: Self

The unit in the last place of 1.0.