Java: Doing one native data type? (e.g. long long double?)

I'm just thinking about whether you can create your own custom data type? Therefore, if you need higher accuracy, which is not supported by one of the main types, you can simply "create" your complete filling of your requirements.

Is it possible and how?

+5
source share
4 answers

Take a look at BigDecimal

Fixed Decimal Continuous Decimal Numbers

- , , (, int, double ..). , BigDecimal ( BigInteger)

Big* - , . , add(..) - , . .

BigDecimal dec = BigDecimal.ZERO;
dec.add(new BigDecimal(5)); // nothing happens
dec = dec.add(new BigDecimal(5)); // this works
+16

Java, , . , - , Java.

, , BigDecimal ( BigInteger) .

+8

.

This does not mean that someone else has not done this before, and is much more effective than ever.

BigInteger and BigDecimal are what you are looking for.

+1
source

All Articles