0

Say I have very big numbers. I know in C we could declare:

long long int // What is equivalent of this in Java?

long double   // and this?

Thanks.

knd
  • 1,662
  • 2
  • 15
  • 27
  • 1
    for primatives: http://www.cafeaulait.org/course/week2/02.html otherwise use BigDecimal and BigInteger – Colin D Oct 25 '12 at 19:43
  • It depends what C you're trying to translate from. Java primitive types have fixed precision across all platforms, but `long long int` and `long double` have different meanings in C depending on your platform. – Louis Wasserman Oct 25 '12 at 20:48

3 Answers3

6

Even in C, a long double and long long int use varying representations on different hardware and compilers. Many compilers consider long double to be the same as doubleβ€”or might give an error.

Similarly, long long has limited support on 16- and 32-bit compilers and especially such platforms.

wallyk
  • 56,922
  • 16
  • 83
  • 148
4

From here we can see that in Java,

a 64 bit = long, 32 bit = int.

Therefore, your long long int in C in a 64 bit linux environment produces a 64 bit int which is equivalent to long in Java. In Windows, 64 bits is _int64.

however, long double is a newer feature and extends the usual length of double and has no primitive equivalent in Java

im so confused
  • 2,091
  • 1
  • 16
  • 25
3

There is no native equivalent in java. You should check out the BigInteger class.

Florin Stingaciu
  • 8,085
  • 2
  • 24
  • 45