Army1987 <ar******@NOSPAM.itwrites:
On Mon, 10 Sep 2007 16:44:03 +0100, Ben Bacarisse wrote:
>(2) If you want speed and a somewhat wider range without
loosing any precision (and you have compiler that can do it) use long
long int.
In many implementations long double is capable to hold any integer
up to ULLONG_MAX + 1 exactly, so it doesn't lose any precision
compared to long long. (It does compared to a bignum library, of
course.)
Many, but not all. It should be possible to determine whether a given
implementation does this using the constants in <limits.hand
<float.h(left as an exercise).
But be careful. If long double *doesn't* support the values you need,
it won't necessarily fail in an obvious manner; you'll just get
results that are *slightly* incorrect. Certain operations that are
specific to integers won't be available. And division works
differently; 3/2==1, but 3.0/2.0==1.5.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"