{"id":2760,"date":"2026-11-10T08:04:01","date_gmt":"2026-11-10T08:04:01","guid":{"rendered":"https:\/\/wiki.designcorner.co.ke\/?dc_term=off-by-one-error"},"modified":"2026-11-10T08:04:01","modified_gmt":"2026-11-10T08:04:01","slug":"off-by-one-error","status":"publish","type":"dc_term","link":"https:\/\/wiki.designcorner.co.ke\/?dc_term=off-by-one-error","title":{"rendered":"Off-by-One Error"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">What it is<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It happens when code starts or stops counting one step too early or late, for example processing 9 items instead of 10 because counting started at 0. Programmers often call it a fencepost error, because a fence with ten gaps needs eleven posts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why it matters for your business<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These small bugs can produce wrong totals, missing records or even security flaws.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Real-world example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A report script skips the last day of every month, so M-Pesa totals look slightly low.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Design Corner tip<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Test code at its boundaries, such as the first and last items, before going live.<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>A common programming bug where a loop or count is wrong by exactly one.<\/p>\n","protected":false},"featured_media":0,"template":"","dc_letter":[20],"dc_topic":[34],"class_list":["post-2760","dc_term","type-dc_term","status-publish","hentry","dc_letter-o","dc_topic-software-and-development"],"_links":{"self":[{"href":"https:\/\/wiki.designcorner.co.ke\/index.php?rest_route=\/wp\/v2\/dc_term\/2760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiki.designcorner.co.ke\/index.php?rest_route=\/wp\/v2\/dc_term"}],"about":[{"href":"https:\/\/wiki.designcorner.co.ke\/index.php?rest_route=\/wp\/v2\/types\/dc_term"}],"version-history":[{"count":0,"href":"https:\/\/wiki.designcorner.co.ke\/index.php?rest_route=\/wp\/v2\/dc_term\/2760\/revisions"}],"wp:attachment":[{"href":"https:\/\/wiki.designcorner.co.ke\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2760"}],"wp:term":[{"taxonomy":"dc_letter","embeddable":true,"href":"https:\/\/wiki.designcorner.co.ke\/index.php?rest_route=%2Fwp%2Fv2%2Fdc_letter&post=2760"},{"taxonomy":"dc_topic","embeddable":true,"href":"https:\/\/wiki.designcorner.co.ke\/index.php?rest_route=%2Fwp%2Fv2%2Fdc_topic&post=2760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}