Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site faron.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!bbnccv!bbncca!linus!faron!bs From: bs@faron.UUCP (Robert D. Silverman) Newsgroups: net.lang.c Subject: Long Longs Message-ID: <491@faron.UUCP> Date: Thu, 27-Feb-86 06:56:02 EST Article-I.D.: faron.491 Posted: Thu Feb 27 06:56:02 1986 Date-Received: Sat, 1-Mar-86 17:20:24 EST Distribution: net Organization: The MITRE Coporation, Bedford, MA Lines: 27 Much of the work I (and others) do involves frequent computations of the form: int a,b,c,d; a = (b*c)/d; a = (b*c) % d; Even when I know (because of normalization or other conditions) that a will fit in a single machine word, C does not allow one to do such computations. The difficulty of course is that b*c frequently will overflow. However, many machines CAN multiply two full words together giving a double length product placed in two adjacent registers. Since there is no 'double register int a' or 'long long a' in C, one is forced however to write an assembler routine to do such arithmetic. However, if one does such computations frequently (e.g. millions of times) the cost of calling a routine to do it is prohibitive. e.g. A three argument call on the VAX takes 16+ usec. Does anyone have a good solution? Does C++ have long longs? Does anyone know of ANY language that does? (Bignums in Lisp don't qualify) Bob Silverman