The need for D-scussion (was Re: D Wishlist)

Henry Spencer henry at utzoo.uucp
Tue Mar 15 05:38:31 AEST 1988


> a function the returns both a % b and a / b at the same time.

ANSI has beaten you to it.  See section 4.10.6.2 in the current X3J11 draft,
which defines the "div" function, returning a struct containing both
quotient and remainder.  (They chose the wrong definition of division, but
I suppose one can't have everything...)

This is probably the best approach to the issue, since not all machines do
in fact efficiently compute both in the same operation.  (The VAX, for
example, has fast instructions that give you either, and a [reportedly]
rather slow instruction that gives you both.)  Better to supply both only
when asked.
-- 
Those who do not understand Unix are |  Henry Spencer @ U of Toronto Zoology
condemned to reinvent it, poorly.    | {allegra,ihnp4,decvax,utai}!utzoo!henry



More information about the Comp.lang.c mailing list