[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

388.0. "Explanation of fencepost error" by VINO::RASPUZZI (Michael Raspuzzi) Thu Jan 22 1987 19:06

    Does anyone know where the term "fencepost error" came from? Also,
    what is the "legend" behind it?
    
    A fencepost error is when a loop counter is off by 1 (because a
    compare or test instruction should be <= instead of < etc).
    
    I'm just curious to see where it came from and how. It isn't
    intuitively obvious (did some assembly language programmer run into
    a fencepost when he had a counter go off by one? :-)).
    
    Mike
T.RTitleUserPersonal
Name
DateLines
388.1fencepost meaning?TOLEDO::VENNERThu Jan 22 1987 20:408
    i just always assumed that it came from fenceposts which divide
    property.  is the fencepost the end of your property or the
    beginning of you neighbors property?  just like in a loop counter
    where you aren't sure whether you want to stop just "before" the end
    condition or just "at" the end condition.
    
    i could be wrong though.
    
388.2Another guessAMIGO::MULLENDan MullenThu Jan 22 1987 21:097
    Could be its from the common mistake of getting one too
many posts when building a closed fence or not getting enough
when building a open fence.

    I could be wrong though.
    
..Dan
388.3Dictionary definitionIOSG::PYEGraham - ALL-IN-1 Sorcerer's ApprenticeFri Jan 23 1987 11:1818
From "The Hacker's Dictionary" Steele, Woods,Finkel etc.:

FENCEPOST ERROR noun.

An "off by one" error: the discrete equivalent of a boundary condition.

This problem is often exhibited in programs containing iterative loops: 
something will be done one time too few or too many. The term comes from the 
following problem: "If you build a fence 100 feet long with posts 10 feet 
apart, how many posts do you need?" (Either 9 or 11 is a better answer than the
obvious 10)



Graham Pye.

PS Maybe the other derivation is that you feel like hitting your head against a 
fence post once you spot the error!
388.4i used to have a truck like that!.VIDEO::OSMANand silos to fill before I feep, and silos to fill before I feepMon Jan 26 1987 16:5017
If two neighbors were quibbling about exactly where their land boundary
lay, they might argue that a fencepost is a slight distance the wrong
way, into one person's property or the other.

Although such a slight amount, it might make a BIG difference to
quarreling neighbors.

Similarly, a range check in a computer program that is supposed to
check for I<1000 and erroneously checks for I<=1000 instead, can make
a BIG difference.

For example, suppose the program is finding the minimum value from a table.
If it uses the I<=1000, it will check one element too many, and that
"non-element" may be 0, which might be less than any actual element seen,
so program prints out 0.

/Eric
388.5can it be?PLDVAX::ZARLENGABigger they are, Harder they hitWed Jan 28 1987 20:136
    Eric,  "you used to have a truck like that"??
    
    	That reminds me of an old joke about two land owners in
    Texas.  You're not letting your sense of humor show, are you??
    
    -mike
388.6In the UK we talk telegraph poles....VERDI::ILESMike IlesFri Jan 30 1987 12:2411
    
    In the UK we talk about telegraph poles rather than fence poles
    but the Hackers dictionary explaination is the one that is correct
    (i.e. if you count spaces between then that is one less than the number
    of poles)
    
    However I have never heard the phrase used in the context of loop
    counters being one out though I shall now!
    
    -Mike-
    
388.7re .5: yes, but one was a Maine farmerVIDEO::OSMANand silos to fill before I feep, and silos to fill before I feepFri Jan 30 1987 20:501
388.8Another explanation - fens post errorSNO78A::BRAHAMPete BrahamSat Jan 31 1987 09:4317
    In the dark ages, the monks of the Venerable Bede had an expression
    'fens post error' (a Vulgate latin term from the latin: 'fenus post
    errorem', meaning 'profit after error'). This was applied to the
    situation where someone made a mistake in their accounts, and somehow
    the maker of the mistake came out showing a profit (I have heard
    rumours that this sometimes happens to people when they do their
    expences). Of course the most common such mistake was one that could
    reasonably be seen to be the sort that anyone could make - eg be off by
    one in a complex calculation. [It should be remebered that calculations
    with only roman numerals were quite difficult, especially
    multiplication and division]. See also 'A Canticle For Leibowitz, pub.
    Harper and Row for the Perennial Library, 1986; P. 321 (paperback ed)
    for further detail. 

(hope this helps)
Pete
388.9fenus post errorem???PASTIS::MONAHANSat Jan 31 1987 18:464
    	I like the explanation in .8 best. Can we request that DEBUG
    and SDA only display in Roman  numerals, to discourage amateur hackers?
    Maybe we could get all of this MCS/French/Norwegian business scrapped
    if we just standardised on *the* international language - Latin.
388.10I'm a doubter...ERIS::CALLASSo many ratholes, so little timeMon Feb 02 1987 17:565
    .8 sounds like folk etymology to me, especially since it comes from an
    after-the-holocaust novel. This genre often creates amusing folk
    etymologies to be witty. Do you have a more traditional reference?
    
    	Jon
388.11XXXVI > XXXIIWBCN::APPELLOFCarl J. AppellofMon Feb 09 1987 18:356
    re .9
    
    TOPS-20 has a monitor call ("system service" to VAXoids) that
    will output a number in most popular radices.  There was once a
    real SPR from a customer which requested Roman Numeral output as
    an option.
388.12VINO::RASPUZZIMichael RaspuzziMon Feb 09 1987 19:566
    re .11:
    
    And we are going to implement said feature as soon as we implement
    fire and smoke :-) :-) :-)
    
    Mike
388.132B::ZAHAREEMichael W. ZahareeTue Feb 10 1987 16:465
    I thought we had a product or two that resembled that remark. 
    
    :-)
    
    - M
388.14Digital has had it a while...FROST::HARRIMANTalk? It's only talk!Tue Feb 10 1987 17:226
    Doesn't DSR do Roman Numerals?
    
    Someone could always bug the developers for an FAO argument for
    them. (%RN?)
    
    /pjh
388.15MAY20::MINOWMartin Minow, MSD A/D, THUNDR::MINOWTue Feb 10 1987 17:347
TeX does Roman Numerals.  I think nroff (Unix formatter) does, too.

There was a request for DECtalk to convert them, but we were able
to squirm out of it.

M.

388.16Digital has it nowPLDVAX::ZARLENGABigger they are, Harder they hitTue Feb 10 1987 22:513
    	For sure VAX Lisp does too.  Both flavors of Roman Numerals.
    
    -mike z
388.17OTS$.....?ANYWAY::GORDONAll I ever do is work &amp; shovel snow!Wed Feb 11 1987 16:233
    	You mean there isn't OTS$CVT_L_TR ?
    
    			;-}
388.18But Only Because TeX Does ItVAXUUM::DYERAiigh!!!Thu Feb 12 1987 12:373
I don't really want to admit it, but VAX DOCUMENT (or whatever we end up calling
 it) can do Roman Numerals too.
  <_Jym_>
388.19XXXVI >> XXXIIDENTON::AMARTINAlan H. MartinSun May 03 1987 16:548
Re .11:

>There was once a real SPR from a customer which requested Roman Numeral
>output as an option.

If I recall correctly, calling the author of that SPR a "customer" really
strains the term to the limit.
				/AHM