This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes BigInteger Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "BigInteger" Watch "BigInteger" New topic
Author

BigInteger

Robbie Harjes
Greenhorn

Joined: Nov 09, 2003
Posts: 22
BigInteger's are fun!, not. To set up some initial values for some BigInteger testing...
doesn't work... So what is the "standard" format? (The best conclusion I've come to is that there not exactly standardized, seeing how the length can change..? i don't know) And how do I convert/cast/whatever method I need for this to work:

Thanks.
Joe Pluta
Ranch Hand

Joined: Jun 23, 2003
Posts: 1376
BigInteger and its sibling BigDecimal are objects, and so you create them using the "new" keyword:
BigInteger myBI = new BigInteger(7);
BigDecimal myBD = new BigDecimal(1.23);
Joe
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Check out the methods of the BigInteger class to find out how to convert from an int to a BigInteger and back again (although if the number will fit into an int, I wonder why you would want to use BigInteger).
[ December 01, 2003: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Robbie Harjes
Greenhorn

Joined: Nov 09, 2003
Posts: 22
Well thanks for the help... But I've come down to just 2 compile time errors. Here's the source code for the program (It's only to find the mod function [remainder] of very large exponential monomials.)

I changed some of the code... realized that the values Y and A are going to be small, but it's only the result of Y^A that requires the BigInteger.
Finally, here are the compile-time errors:

[ December 01, 2003: Message edited by: Robbie Harjes ]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11170
    
  16

Forgive me, but what am i missing??? i don't see a constructor for BigInteger that accepts an int. i think that's what the compiler is complaining about.
you can pass it a string...
BigInteger big = new BigInteger("7");
that seems to fix one error...
the other is that BigInter.mod() takes a BigInteger, not a long...
and then...
intvalue doesn't take any parameter, you just call it on your BigInteger object you want the value of...
integer i = big.intvalue();


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BigInteger
 
Similar Threads
BigInteger exponents - how?
how to compare the values in arrays
using the math class for rounding numbers
How do you determine syntax in the Java Libraries?
Need help on animation using GUI Builder.