Is there any replacement of long double in java?
c, java
Solution
Though not a replacement, you can use java.lang.math.BigDecimal.You can roughly store billion of digits until you run out of memory. Its an arbitrary precision class, it will get as large as you'd like until your computer runs out of memory.
As per the documentation of BigDecimal:
Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a non-negative 32-bit integer scale, which represents the number of digits to the right of the decimal point. The number represented by the BigDecimal is (unscaledValue/10scale). BigDecimal provides operations for basic arithmetic, scale manipulation, comparison, hashing, and format conversion.
Problem
I was reading about data types in C. I found the range of `long double` is more than that of `double` in java. For very huge number we can use long double in C. If I want to store the same number in java what we have to do? which datatype we can use? double in java takes 8 bytes(64 bits) IEEE 754. it Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative). ``` longdouble in c takes 10 bytes (80 bits) ``` Can anyone tell me is there any replacement of longdouble in java