- a = b; // From int to BigInteger...
- b = a; // ...and back, no casts required!
- /*
- * If a were too big for an int you'd get a runtime exception.
- * The Big Integer Library throws C-strings (that is,
- * `const char *'s) when something goes wrong. It's a good idea
- * to catch them; the `try/catch' construct wrapping all this
- * code is an example of how to do this. Some C++ compilers need
- * a special command-line option to compile code that uses
- * exceptions.
- */
+ /* Any primitive integer can be converted implicitly to a
+ * BigInteger. */
+ a = b;
+
+ /* The reverse conversion requires a method call (implicit
+ * conversions were previously supported but caused trouble).
+ * If a were too big for an int, the library would throw an
+ * exception. */
+ b = a.toInt();