Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!decvax!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.lang.c Subject: Re: Addition of pointers Message-ID: <542@lakart.UUCP> Date: 9 May 89 14:09:35 GMT References: <2299@mit-caf.MIT.EDU> Organization: Lakart Corporation, Newton, MA Lines: 32 From article <2299@mit-caf.MIT.EDU>, by vlcek@mit-caf.MIT.EDU (Jim Vlcek): > In article <4093@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >>In article <563@lzaz.ATT.COM>, hutch@lzaz.ATT.COM (R.HUTCHISON) writes: >>> midpoint_pointer = (start_pointer + end_pointer) / 2; >> >>You're right. It's a valid operation. > > In what sense? It's invalid C, that's for sure. > > All you people who want to be able to add pointers, consider this: > What is the significance of the sum of ``the location of Boston'' and > ``the location of Detroit?'' Answer: none. Taking this to it's (logical??????) conclusion, is not the point half way between Boston and Detroit (say Elmira in Upstate NY :-) ) best defined as: Start at Boston, and go 1/2 way to Detroit, or in pointer arithmetic: midpoint_pointer = start_pointer + (end_pointer - start_pointer) / 2; Now, in scalar maths this is the same as the formula above, but pointers are _NOT_ scalars: adjusting the formula again: midpoint_pointer = start_pointer / 2 + end_pointer / 2; Now, just what the hell is half a pointer??????? -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+