Long Longs
Jonathan P. Leech
jon at cit-vax.ARPA
Mon Mar 3 12:24:47 AEST 1986
> From: "Robert D. Silverman" <bs%faron.uucp at BRL.ARPA>
> Subject: Long Longs
>
> ... Various reasons for wanting 'long longs' deleted
>
> Does C++ have long longs? Does anyone know of ANY language that does?
> (Bignums in Lisp don't qualify)
>
> Bob Silverman
Some C compilers have them, especially if the hardware supports
it. I know that C on ELXSI Unix and UTS (Amdahl) Unix has them. Note
that (even if they were added to the ANSI standard) there is nothing
prohibiting the COMPILER from generating function calls just as you
would - many compilers already do this for floating point operations
if there is no hardware f.p. - so there's no guaranteed speedup.
You could define a class in C++ containg 64-bit longs and
overload the normal arithmetic operations to work on them; getting it
to generate the 'proper' code for
int b, c, d;
longlong result;
result = (b * c) / d;
would be more difficult. My limited experience with C++ makes me think
that you would have to define a new class equivalent to int except
that result of '*' is a longlong (or whatever you want to call it).
C++ could generate such code inline.
Final cautionary note: [ from K&R Appendix A Sec. 7 (pg 185)
Expressions ]:
"... Expressions involving a commutative and associative operator
(*, +, &, |, ^) may be rearranged arbitrarily, even in the
presence of parentheses; to force a particular order of evaluation
an explicit temporary must be used."
I believe the ANSI draft lets you specify order of evaluation
with the unary '+' operator, so you would want
a = +(b * c) / d;
whenever ANSI compilers finally arrive.
-- Jon Leech (jon at csvax.caltech.edu)
__@/
More information about the Comp.lang.c
mailing list