New operator: /*

jrv at mitre-bedford.ARPA jrv at mitre-bedford.ARPA
Mon Aug 27 08:56:00 AEST 1984

I was using a FORTH (pardon the profanity) the other day and
found a neat new operator: /*. It has the effect of multiplying
two integers, then dividing by a third WITH A DOUBLE LENGTH
INTERMEDIATE, so it won't overflow unless the final result does.
It's handy when floating point operations are unavailable or too
slow (such as in graphics). Most machines with multiplication
give a double length result, and most with division can start
with a double length dividend. However, C doesn't presently
give us access to these operations. My question: what's a
reasonable C syntax for it?  The obvious one is a/b*c, but it's
already spoken for. Are there compilers that let you get this
effect by explicitly declaring the intermediate:
	short a,b,c,d;
	long temp;

Of course, you can define this as a a function in assembly
language, but the calling overhead would reduce the speed advantage.

Any thoughts would be welcome.		- Jim Van Zandt

More information about the Comp.lang.c mailing list