(a) Integer arethmetic is always exact, if there is neither an underflow nor an overflow.
(b) There is no such thing as a "long long" in the C++ standard:
(3.9.1.2) There are four signed integer types: "signed char", "short int", "int", and "long int." |
(c) The size of these types is implementation-defined. The size increases in the given order, and "signed char" is the size of the machines character representation size. That's about all you are guaranteed.
(d) You can check ranges with the functions defined in <numeric_limits>. There you can also check if your floating point arithmetic is IEEE 754 compliant:
static const bool is_iec559
. If it is, you could use the arithmetic to perform exact integer calculations in certain ranges, but this is rather complicated (there is a paper by Clarkson: "Safe and effective determinant evaluation" which uses this technique (I think that's the first time doubles were used as ints), since back then (1992) 64 bit wasn't available and the FPU was faster than multiple CPU calculations. But really, it is rather complicated.)
(e) Have a look at gmpxx (
http://gmplib.org/). It's a library providing the type mpz_class, which can be used exactly like an integer but has an "infinite" size (it grows as the number it holds grows, until you're out of ram).
Hope that helps.