<s>
An	O
off-by-one	B-Error_Name
error	I-Error_Name
or	O
off-by-one	B-Error_Name
bug	O
(	O
known	O
by	O
acronyms	O
OBOE	O
,	O
OBO	O
,	O
OB1	B-Error_Name
and	O
OBOB	B-Error_Name
)	O
is	O
a	O
logic	B-General_Concept
error	I-General_Concept
involving	O
the	O
discrete	O
equivalent	O
of	O
a	O
boundary	O
condition	O
.	O
</s>
<s>
It	O
often	O
occurs	O
in	O
computer	B-General_Concept
programming	I-General_Concept
when	O
an	O
iterative	O
loop	O
iterates	O
one	O
time	O
too	O
many	O
or	O
too	O
few	O
.	O
</s>
<s>
Both	O
of	O
these	O
alternatives	O
can	O
cause	O
off-by-one	B-Error_Name
errors	I-Error_Name
.	O
</s>
<s>
Pascal	B-Application
has	O
arrays	O
with	O
user-defined	O
indices	O
.	O
</s>
<s>
A	O
fencepost	O
error	O
(	O
occasionally	O
called	O
a	O
telegraph	O
pole	O
,	O
lamp-post	O
,	O
or	O
picket	O
fence	O
error	O
)	O
is	O
a	O
specific	O
type	O
of	O
off-by-one	B-Error_Name
error	I-Error_Name
.	O
</s>
<s>
"	O
Fencepost	O
error	O
"	O
can	O
,	O
in	O
rare	O
occasions	O
,	O
refer	O
to	O
an	O
error	O
induced	O
by	O
unexpected	O
regularities	O
in	O
input	O
values	O
,	O
which	O
can	O
(	O
for	O
instance	O
)	O
completely	O
thwart	O
a	O
theoretically	O
efficient	O
binary	O
tree	O
or	O
hash	B-Error_Name
function	I-Error_Name
implementation	O
.	O
</s>
<s>
In	O
larger	O
numbers	O
,	O
being	O
off	B-Error_Name
by	I-Error_Name
one	I-Error_Name
is	O
often	O
not	O
a	O
major	O
issue	O
.	O
</s>
<s>
In	O
smaller	O
numbers	O
,	O
however	O
,	O
and	O
specific	O
cases	O
where	O
accuracy	O
is	O
paramount	O
committing	O
an	O
off-by-one	B-Error_Name
error	I-Error_Name
can	O
be	O
disastrous	O
.	O
</s>
<s>
An	O
example	O
of	O
this	O
error	O
can	O
occur	O
in	O
the	O
computational	O
language	O
MATLAB	B-Language
with	O
the	O
linspace( )	O
linear	O
interpolation	O
function	O
,	O
whose	O
parameters	O
are	O
(	O
lower	O
value	O
,	O
upper	O
value	O
,	O
number	O
of	O
values	O
)	O
and	O
not	O
(	O
lower	O
value	O
,	O
upper	O
value	O
,	O
number	O
of	O
increments	O
)	O
.	O
</s>
<s>
A	O
common	O
off-by-one	B-Error_Name
error	I-Error_Name
which	O
results	O
in	O
a	O
security-related	O
bug	O
is	O
caused	O
by	O
misuse	O
of	O
the	B-Language
C	I-Language
standard	I-Language
library	I-Language
strncat	O
routine	O
.	O
</s>
<s>
Off-by-one	B-Error_Name
errors	I-Error_Name
are	O
common	O
in	O
using	O
the	O
C	B-Language
library	I-Language
because	O
it	O
is	O
not	O
consistent	O
with	O
respect	O
to	O
whether	O
one	O
needs	O
to	O
subtract	O
1	O
byte	O
–	O
functions	O
like	O
fgets( )	O
and	O
strncpy	O
will	O
never	O
write	O
past	O
the	O
length	O
given	O
them	O
(fgets( )	O
subtracts	O
1	O
itself	O
,	O
and	O
only	O
retrieves	O
(	O
length−1	O
)	O
bytes	O
)	O
,	O
whereas	O
others	O
,	O
like	O
strncat	O
will	O
write	O
past	O
the	O
length	O
given	O
them	O
.	O
</s>
