[comp.lang.c] fixed point

chris@mimsy.umd.edu (Chris Torek) (02/16/90)

(My apologies for the extensive quoting: I trimmed as much as I thought
reasonable.)

In article <17910@rpp386.cactus.org> woody@rpp386.cactus.org
(Woodrow Baker) suggests that ANSI C should have included:
>>>>FIXED  i.e. fixed point math. ... would deal with chars, ints, longs
>>>>and quads.  There would be an assumed binary point in the middle of the
>>>>data...

(`short' seems to be missing from the above list.)

In article <1990Feb12.182343.14269@utzoo.uucp> henry@utzoo.uucp
(Henry Spencer) points out:
>>>But *I* want the assumed binary point three bits from the right! :-)  This
>>>whole area is a massive swamp of conversion rules, overflow handling, etc.

In article <1990Feb13.114041.4178@bath.ac.uk> exspes@bath.ac.uk (P E Smee)
writes:
>>PL/1 offered that.  In years of PL/1 programming, I believe I only ever
>>saw two or three programs (by anyone) that used it.  ... [Things were]
>>so baroque that it was actually usually easier to simply declare
>>everything as 'fixed bin (n,0)' (effectively, int/long/short) and [do
>>the work yourself].

This, of course, was Henry's point: fixed-point support is not nearly
as simple as it first appears.

In article <17950@rpp386.cactus.org> woody@rpp386.cactus.org (Woodrow Baker)
writes:
>People, missed my point, that fixed point does not require conversions.
>A fixed int and an int are the same thing.  i.e., they should substitue
>for each other.  It is merely where you have the binary point.  Conversion
>to and from float, fixed, and int are not a problem.  fixed to float is
>real easy, float to fixed is also easy. ...

You cannot have it both ways:  Either a fixed int and an int are the
same thing---in which case, you do not need `fixed int' in the
language, because it is just another word for `int'---or they are
different.  If they are different, it is an untested change to C and
does not belong in the standard.

If the fixed point you propose is simply an alias, all you need to do is

	typedef long fixedpoint;

If the fixed point you propose comes with conversions, Henry's objection
applies.

`If you want PL/I, you know where to find it,'
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris