Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Long just isn't long enough ..

 
Dave Jones
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a spec in which I'm required to hold a 20 digit number. as you know, long can hold (almost) up to 19 (2^63 -1).

Any suggestions ?

Thanks a lot
Dave
 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The keyword to search for is the "BigInt" class.

Kaydell
 
Dave Jones
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, I know about BigInt, and actually, I think that BigInteger is even better for my use, but isn't this solution a bit"too much" for what I need ?
isn't there something 'smaller' friendlier than this ?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15359
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So long is too small, but you think BigInteger is too big? Why do you think that BigInteger is "too much" for what you need?

There's not really something in between...
 
Dave Jones
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, reading a bit about BigInteger, I understood that it holds many options and possibilities, more than I need. So I was wondering if there is something in the middle.
If you say there isn't, well, BigInteger- here I come !!!

Thanks guys(and 'gals').
 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, is there both "BigInt" and "BigInteger"?

Kaydell
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15359
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there is no "BigInt" in the standard Java API - you could have found this out quickly by looking at the API documentation.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you actually need to do numerical computations with this 20-digit number? If not, maybe a String would do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic