Questions tagged [biginteger]

BigInteger is an arbitrary-precision arithmetic type in Java, C#, and other languages. It behaves like a signed integer whose size is limited only by available memory.

BigInteger is an arbitrary-precision arithmetic type in the .NET Framework, Java, and other languages. It behaves like a signed integer whose size is limited only by available memory.

1971 questions
32
votes
4 answers

How to convert strings to bigInt in JavaScript

I need to convert a string to BigInt like BigInteger in Javascript Example var reqId = "78099864177253771992779766288266836166272662"; var result = parseInt(reqId); document.write(result); Resultant value not matching since JavaScript only allows…
rselvaganesh
  • 1,032
  • 2
  • 18
  • 30
32
votes
9 answers

How to convert BigInteger to String in java

I converted a String to BigInteger as follows: Scanner sc=new Scanner(System.in); System.out.println("enter the message"); String msg=sc.next(); byte[] bytemsg=msg.getBytes(); BigInteger m=new BigInteger(bytemsg); Now I want my string back. I'm…
condinya
  • 950
  • 4
  • 12
  • 19
32
votes
9 answers

java.math.BigInteger cannot be cast to java.lang.Long

I've got List dynamics. And I want to get max result using Collections. This is my code: List dynamics=spyPathService.getDynamics(); Long max=((Long)Collections.max(dynamics)).longValue(); This is my getDynamics: public…
Tony
  • 485
  • 2
  • 7
  • 13
30
votes
5 answers

Logarithm for BigInteger

I have a BigInteger number, for example beyond 264. Now i want to calculate the logarithm of that BigInteger number, but the method BigInteger.log() does not exist. How do I calculate the (natural) logarithm of my large BigInteger value?
RAVITEJA SATYAVADA
  • 2,503
  • 23
  • 56
  • 88
30
votes
5 answers

byte[] to unsigned BigInteger?

Motivation: I would like to convert hashes (MD5/SHA1 etc) into decimal integers for the purpose of making barcodes in Code128C. For simplicity, I prefer all the resulting (large) numbers to be positive. I am able to convert byte[] to BigInteger in…
Doochz
  • 1,039
  • 2
  • 14
  • 25
30
votes
2 answers

Where is my System.Numerics namespace?

I'm using Visual Studio 2010 and trying to use the BigInteger type in a C# program. This type is supposed to be available in System.Numerics namespace, but I don't seem to have that installed in the .Net 4.0 framework. When I type "using…
Kevin
  • 4,798
  • 19
  • 73
  • 120
30
votes
9 answers

BigInteger.pow(BigInteger)?

I'm playing with numbers in Java, and want to see how big a number I can make. It is my understanding that BigInteger can hold a number of infinite size, so long as my computer has enough Memory to hold such a number, correct? My problem is that…
PeterW
  • 309
  • 1
  • 3
  • 3
29
votes
3 answers

How to deal with big numbers in javascript

I'm looking for a Mathematical solution that deals with really (long, big, huge, storms) numbers. I haven't found anything yet, But I don't wanna think that this problem hasn't be solve at this time. I'm looking for an easy Number solution, like…
crsuarezf
  • 1,201
  • 3
  • 18
  • 33
29
votes
15 answers

C++ handling very large integers

I am using the RSA Algorithm for encryption/decryption, and in order to decrypt the files you have to deal with some pretty big values. More specifically, things like P = C^d % n = 62^65 % 133 Now that is really the only calculations that ill be…
Tomek
28
votes
3 answers

Why is this long overflowing to -1, instead of the minimum value for the type?

I have the following code that returns the number of nodes in a tree when a complete Binary Tree is layer layers tall: public static long nNodesUpToLayer(int layer) { if (layer < 0) throw new IllegalArgumentException( "The layer…
Carcigenicate
  • 43,494
  • 9
  • 68
  • 117
28
votes
5 answers

java: how for loop work in the case of BigInteger

I want to take Input from the user as Big-Integer and manipulate it into a For loop BigInteger i; for(BigInteger i=0; i<=100000; i++) { System.out.println(i); } But it won't work can any body help me.
Sanjeev
  • 1,087
  • 8
  • 18
  • 27
27
votes
2 answers

Converting BigInteger to binary string

Can we convert Biginteger to binary string String s1 = "0011111111101111111111111100101101111100110000001011111000010100"; String s2 = "0011111111100000110011001100110011001100110011001100110011001100"; BigInteger bi1, bi2, bi3; bi1 =…
Kailash
  • 642
  • 2
  • 9
  • 15
27
votes
8 answers
26
votes
1 answer

How to divide two native JavaScript BigInt's and get a decimal result

Here's what I've tried so far. I'm looking to get a 12.34: BigInt('12340000000000000000') / BigInt('1000000000000000000') 12n Number(BigInt('12340000000000000000') / BigInt('1000000000000000000')) 12 FWIW, when I use the JSBI lib, it's working…
robmisio
  • 1,066
  • 2
  • 12
  • 20
25
votes
4 answers

How can I convert an absolutely massive number to a string in a reasonable amount of time?

This is quite an odd problem I know, but I'm trying to get a copy of the current largest prime number in a file. Getting the number in integer form is fairly easy. I just run this. prime = 2**74207281 - 1 It takes about half a second and it works…
Daffy
  • 841
  • 9
  • 23