Results 1 to 10 of 10
 12262010, 12:17 PM #1Senior Member
 Join Date
 Aug 2010
 Posts
 127
 Rep Power
 0
inputting large numbers into java
I want to do an analysis (once) using a java program on a very large amount of digits (1000). My question is: how do I hard code it or input it in my program? I tried hard coding it, but it won't except literals that exceed the int limit.
edit: So I want those 1000 digits to go into a 1000 member integer array.

 12262010, 01:34 PM #3Member
 Join Date
 Dec 2010
 Location
 Philippines
 Posts
 5
 Rep Power
 0
Try to use double data type
double myvar = 0.0;
http://thecodewall.blogspot.comLast edited by thecodewall; 12262010 at 01:38 PM.
 12262010, 01:57 PM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,820
 Blog Entries
 7
 Rep Power
 21
 12262010, 02:26 PM #5Member
 Join Date
 Dec 2010
 Location
 Philippines
 Posts
 5
 Rep Power
 0
thanks for this info.
The Code Wall
 12262010, 02:40 PM #6Senior Member
 Join Date
 Aug 2010
 Posts
 127
 Rep Power
 0
How do you hardcode BigIntegers?
 12262010, 02:45 PM #7
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,820
 Blog Entries
 7
 Rep Power
 21
 12262010, 02:46 PM #8Member
 Join Date
 Dec 2010
 Location
 Philippines
 Posts
 5
 Rep Power
 0
// sample from Programming tutorials and source code examples
import java.math.BigInteger;
public class Main {
public static void main(String[] argv) throws Exception {
// Create via a string
BigInteger bi1 = new BigInteger("1234567890123456890");
// Create via a long
BigInteger bi2 = BigInteger.valueOf(123L);
bi1 = bi1.add(bi2);
bi1 = bi1.multiply(bi2);
bi1 = bi1.subtract(bi2);
bi1 = bi1.divide(bi2);
bi1 = bi1.negate();
int exponent = 2;
bi1 = bi1.pow(exponent);
}
}
http://thecodewall.blogspot.com
 12262010, 02:55 PM #9Senior Member
 Join Date
 Aug 2010
 Posts
 127
 Rep Power
 0
Ah, this is a start. That would about halve the lines needed. So hardcoding a 1000 digits into an integer array would go like this:
Java Code:BigInteger temp; temp=new BigInteger("first 20 digits"); f1(temp); temp=new BigInteger("next 20 digits"); f1(temp); temp=new BigInteger("next 20 digits"); f1(temp); ... ... temp=new BigInteger("last 20 digits"); f1(temp);
 12262010, 02:59 PM #10
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,820
 Blog Entries
 7
 Rep Power
 21
cenosillicaphobia: the fear for an empty beer glass
Similar Threads

Getting rid of commas in large numbers?
By wwuster in forum Advanced JavaReplies: 12Last Post: 03052012, 11:35 AM 
Inputting some text in a GUI.
By AJArmstron@aol.com in forum New To JavaReplies: 6Last Post: 04152010, 01:20 PM 
crunching large numbers
By aaroncarpet in forum Advanced JavaReplies: 26Last Post: 11302009, 03:10 AM 
Crunching large numbers part II
By aaroncarpet in forum Advanced JavaReplies: 0Last Post: 11282009, 06:34 AM 
Inputting custom numbers
By Jakora33 in forum New To JavaReplies: 14Last Post: 09082009, 09:14 PM
Bookmarks