Well, as you know, doubles and floats are a specific number of bits wide. That means you can only cram so much information into them. 4.2 * 12.09 is no problem. But how about 34998729873948792879387948793879234.019872987349871234908798734928734928734987 * 0.00000000000000000000000000000023498729384729834792834792837492837492834729843273928?
BigInteger provides analogues to all of Java's primitive integer operators, and all relevant methods from java.lang.Math. Additionally, BigInteger provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations.
Originally posted by Marco Vanoli: ...Here's Long.MAX_VALUE: 9223372036854775807 Here's a bigger number: 3419229223372036854775807 Here it is as a double: 3.419229223372037E24...
Yeah, I recall using BigInteger for handling very large numbers when I was writing the "ultimate" factoring program. (Doesn't everyone write one of these?) My program used BigInteger until the remainder was "small" enough to use primitives, when it switched over to long. I never actually verified whether this switch was more efficient.