Skip to content
Advertisement

How to enable my program to receive small to extensive, large numbers > 2.14 billion

I’m currently coding a program that converts a number to its word format, and thus far, I’ve written a code that only accepts no larger than the max value of an integer (2.14 billion). I was wondering how I would scale up the program’s capability to accepting larger numbers.

(Edited): I’ve converted all my int values to long datatypes. I was able to scale the limitation up from 2.14 to 999 billion, though shouldn’t be the max value of a long datatype is 9 quintillion?

The converter code:

JavaScript

Advertisement

Answer

I think you could use BigInteger https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement