Can Java work with "long double" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can Java work with "long double"

8th Sep 2022, 5:34 PM
Mugabi Joshua
Mugabi Joshua - avatar
5 Answers
+ 1
Yes, Java supports the `double` data type for representing double-precision floating-point numbers. The `long` data type, however, is specifically for integers, not floating-point numbers. If you need to work with floating-point numbers in Java, you would typically use `double` or `float` for single-precision floating-point numbers. Example of a `double` variable in Java: ```java double myDouble = 3.14; ``` If you need higher precision than `double`, you might consider using the `BigDecimal` class for arbitrary-precision arithmetic.
2nd Feb 2024, 12:06 AM
Mugabi Joshua
Mugabi Joshua - avatar
+ 6
There is long type. ( whole numbers) And double type. ( precision valued numbers) No long double? What it is?
8th Sep 2022, 5:40 PM
Jayakrishna 🇮🇳
+ 1
But take a try in cpp
30th Sep 2022, 8:44 AM
Mugabi Joshua
Mugabi Joshua - avatar
+ 1
Show me how to use long type
30th Sep 2022, 8:44 AM
Mugabi Joshua
Mugabi Joshua - avatar
+ 1
But not in java. in java, long num = 123457890000000_000L; // no underscore needed but add suffix L for over integer value.
30th Sep 2022, 12:26 PM
Jayakrishna 🇮🇳