chris@mimsy.UUCP (Chris Torek) (04/12/89)
In article <8420@xanth.cs.odu.edu> kremer@cs.odu.edu (Lloyd Kremer) writes: >Why was it decided that off_t should be signed? ... >it doesn't make sense to have a negative offset into a file. You do need to be able to seek backwards, but that excuse is not good enough. It seems likely that off_t is signed because it has always been signed. Still, 2^32-1 is not big enough; we need 64-bit integers. (The 4.2BSD file system format has room for 64 bit sizes.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
chris@mimsy.UUCP (Chris Torek) (04/13/89)
In article <1430@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes: >since [lseek] can use [its off_t] argument ... as a >possibly-negative offset relative to the current position in the file or >to the end of the file, it has to be signed. Well, no, not really. Unsigned arithmetic is modular arithmetic; this produces the same result, although not in as intuitive a manner. If (off_t) is (unsigned long) and if that is 32 bits, -(off_t)100 is 4294967196, and (off_t)150 + -(off_t)100 is 50. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris