2

So, I was doing some testing around to see what the max limit for Integer was, and it is 2147483647. But, I wanted more.

So I switched over to Long, which based on my experiments, the max value for that is 9199999999999999999, which is only just under 9.2 quadrillion I believe.

But, that is still not enough, I want to go to at least 999 Septillion, etc. Is this possible? If not, could I be given a way to convert numbers to letter variable form; (1q, 2S, etc.)? And if I convert them to variable form.

Is there a way to get the actual value of the variable for my config file sake? I will need it for shops and rankups and other stuff.

GhostCat
  • 137,827
  • 25
  • 176
  • 248
Not_A_Dev
  • 91
  • 8
  • try BigDecimal. – Pirate Dec 09 '21 at 05:15
  • How are your tags for Minecraft and bukkit relevant? If not relevant, delete. – Basil Bourque Dec 09 '21 at 05:29
  • *So, I was doing some testing around* ... just as note: those are things that you actually should approach differently. Languages have **specifications**. So, your very first step should be to do real research. Any good book about java explains the type system, and the semantics (such as range) of the different types. Sure, then writing some test code to play with that is great ... but **never** assume that you can fully understand the semantics of types and languages in general by **testing** things. – GhostCat Dec 09 '21 at 07:48
  • 1
    Those limits: Integer.MAX_VALUE, Long.MAX_VALUE. – Joop Eggen Dec 09 '21 at 07:49
  • @GhostCat just because I said "I was doing some testing around" doesn't mean I went in blindly and used stuff I didn't understand. I'm not an idiot smfh. – Not_A_Dev Dec 10 '21 at 01:19
  • Nothing in your question implies that you had a look at *specifications*. I didn't say you went in blindly, and I didn't call you names. Anyway, sorry if it came over the wrong way. – GhostCat Dec 10 '21 at 06:30

1 Answers1

3

BigDecimal

You can use BigDecimal. BigDecimal represents an immutable arbitrary-precision signed decimal number. It consists of two parts:

Unscaled value – an arbitrary precision integer Scale – a 32-bit integer representing the number of digits to the right of the decimal point For example, the BigDecimal 3.14 has the unscaled value of 314 and the scale of 2.

We use BigDecimal for high-precision arithmetic. We also use it for calculations requiring control over scale and rounding off behavior. One such example is calculations involving financial transactions.

We can create a BigDecimal object from String, character array, int, long, and BigInteger:

BigDecimal number = new BigDecimal("45");

BigInteger

Or you can use BigInteger.

BigInteger number = new BigInteger("1234567890987654321");

BigInteger represents immutable arbitrary-precision integers. It is similar to the primitive integer types but allows arbitrary large values.

It is used when integers involved are larger than the limit of long type. For example, the factorial of 50 is 30414093201713378043612608166064768844377641568960512000000000000. This value is too big for an int or long data type to handle. It can only be stored in a BigInteger variable.

It is widely used in security and cryptography applications.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Pirate
  • 2,886
  • 4
  • 24
  • 42