<s>
In	O
computer	B-General_Concept
science	I-General_Concept
and	O
numerical	B-General_Concept
analysis	I-General_Concept
,	O
unit	B-Algorithm
in	I-Algorithm
the	I-Algorithm
last	I-Algorithm
place	I-Algorithm
or	O
unit	O
of	O
least	O
precision	O
(	O
ulp	O
)	O
is	O
the	O
spacing	O
between	O
two	O
consecutive	O
floating-point	B-Algorithm
numbers	I-Algorithm
,	O
i.e.	O
,	O
the	O
value	O
the	O
least	O
significant	O
digit	O
(	O
rightmost	O
digit	O
)	O
represents	O
if	O
it	O
is	O
1	O
.	O
</s>
<s>
It	O
is	O
used	O
as	O
a	O
measure	O
of	O
accuracy	O
in	O
numeric	B-General_Concept
calculations	O
.	O
</s>
<s>
Another	O
definition	O
,	O
suggested	O
by	O
John	O
Harrison	O
,	O
is	O
slightly	O
different	O
:	O
is	O
the	O
distance	O
between	O
the	O
two	O
closest	O
straddling	O
floating-point	B-Algorithm
numbers	I-Algorithm
and	O
(	O
i.e.	O
,	O
those	O
with	O
and	O
)	O
,	O
assuming	O
that	O
the	O
exponent	O
range	O
is	O
not	O
upper-bounded	O
.	O
</s>
<s>
The	O
IEEE	O
754	O
specification	O
—	O
followed	O
by	O
all	O
modern	O
floating-point	B-Algorithm
hardware	O
—	O
requires	O
that	O
the	O
result	O
of	O
an	O
elementary	O
arithmetic	O
operation	O
(	O
addition	O
,	O
subtraction	O
,	O
multiplication	O
,	O
division	O
,	O
and	O
square	O
root	O
since	O
1985	O
,	O
and	O
FMA	O
since	O
2008	O
)	O
be	O
correctly	O
rounded	O
,	O
which	O
implies	O
that	O
in	O
rounding	O
to	O
nearest	O
,	O
the	O
rounded	O
result	O
is	O
within	O
0.5	O
ulp	O
of	O
the	O
mathematically	O
exact	O
result	O
,	O
using	O
John	O
Harrison	O
's	O
definition	O
;	O
conversely	O
,	O
this	O
property	O
implies	O
that	O
the	O
distance	O
between	O
the	O
rounded	O
result	O
and	O
the	O
mathematically	O
exact	O
result	O
is	O
minimized	O
(	O
but	O
for	O
the	O
halfway	O
cases	O
,	O
it	O
is	O
satisfied	O
by	O
two	O
consecutive	O
floating-point	B-Algorithm
numbers	I-Algorithm
)	O
.	O
</s>
<s>
Reputable	O
numeric	B-General_Concept
libraries	B-Library
compute	O
the	O
basic	O
transcendental	O
functions	O
to	O
between	O
0.5	O
and	O
about	O
1	O
ulp	O
.	O
</s>
<s>
Only	O
a	O
few	O
libraries	B-Library
compute	O
them	O
within	O
0.5	O
ulp	O
,	O
this	O
problem	O
being	O
complex	O
due	O
to	O
the	O
Table-maker	O
'	O
s	O
dilemma	O
.	O
</s>
<s>
Let	O
be	O
a	O
positive	O
floating-point	B-Algorithm
number	I-Algorithm
and	O
assume	O
that	O
the	O
active	O
rounding	O
mode	O
is	O
round	O
to	O
nearest	O
,	O
ties	O
to	O
even	O
,	O
denoted	O
.	O
</s>
<s>
This	O
is	O
demonstrated	O
in	O
the	O
following	O
Haskell	B-Language
code	O
typed	O
at	O
an	O
interactive	O
prompt	O
:	O
</s>
<s>
Since	O
the	O
significand	B-Algorithm
for	O
a	O
single-precision	O
number	O
contains	O
24	O
bits	O
,	O
the	O
first	O
integer	O
that	O
is	O
not	O
exactly	O
representable	O
is	O
224+1	O
,	O
and	O
this	O
value	O
rounds	O
to	O
224	O
in	O
round	O
to	O
nearest	O
,	O
ties	O
to	O
even	O
.	O
</s>
<s>
The	O
following	O
example	O
in	O
Java	B-Language
approximates	O
as	O
a	O
floating	B-Algorithm
point	I-Algorithm
value	I-Algorithm
by	O
finding	O
the	O
two	O
double	O
values	O
bracketing	O
:	O
.	O
</s>
<s>
Another	O
example	O
,	O
in	O
Python	B-Language
,	O
also	O
typed	O
at	O
an	O
interactive	O
prompt	O
,	O
is	O
:	O
</s>
<s>
Similarly	O
to	O
Example1	O
,	O
the	O
result	O
is	O
253	O
because	O
the	O
double-precision	O
floating-point	B-Algorithm
format	I-Algorithm
uses	O
a	O
53-bit	O
significand	B-Algorithm
.	O
</s>
<s>
and	O
boost::math::float_advance	O
to	O
obtain	O
nearby	O
(	O
and	O
distant	O
)	O
floating-point	B-Algorithm
values	O
,	O
and	O
boost::math::float_distance(a, b )	O
to	O
calculate	O
the	O
floating-point	B-Algorithm
distance	O
between	O
two	O
doubles	O
.	O
</s>
<s>
The	O
C	B-Language
language	I-Language
library	O
provides	O
functions	O
to	O
calculate	O
the	O
next	O
floating-point	B-Algorithm
number	I-Algorithm
in	O
some	O
given	O
direction	O
:	O
nextafterf	O
and	O
nexttowardf	O
for	O
float	B-Algorithm
,	O
nextafter	O
and	O
nexttoward	O
for	O
double	O
,	O
nextafterl	O
and	O
nexttowardl	O
for	O
long	O
double	O
,	O
declared	O
in	O
<math.h>	O
.	O
</s>
<s>
The	O
Java	B-Language
standard	O
library	O
provides	O
the	O
functions	O
and	O
.	O
</s>
<s>
They	O
were	O
introduced	O
with	O
Java	B-Language
1.5	O
.	O
</s>
<s>
The	O
Swift	B-Application
standard	O
library	O
provides	O
access	O
to	O
the	O
next	O
floating-point	B-Algorithm
number	I-Algorithm
in	O
some	O
given	O
direction	O
via	O
the	O
instance	O
properties	O
nextDown	O
and	O
nextUp	O
.	O
</s>
<s>
It	O
also	O
provides	O
the	O
instance	O
property	O
ulp	O
and	O
the	O
type	O
property	O
ulpOfOne	O
(	O
which	O
corresponds	O
to	O
C	B-Language
macros	O
like	O
FLT_EPSILON	O
)	O
for	O
Swift	B-Application
's	O
floating-point	B-Algorithm
types	O
.	O
</s>
