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
20
votes
5 answers

What variable type can I use to hold huge numbers (30+ digits) in java?

Is there a really large variable type I can use in Java to store huge numbers (up to around forty digits)? long's maximum value is 9223372036854775807, which is 19 digits -- not nearly large enough. I'm trying to create a calculator that can handle…
Jonathan Lam
  • 16,831
  • 17
  • 68
  • 94
19
votes
1 answer

Number of digits of GMP integer

Is there an easy way to determine the number of digits a GMP integer has? I know you can determine it through a log, but I was wondering if there was something built into the library that I'm missing. The only thing I've found in the manual…
Darkenor
  • 4,349
  • 8
  • 40
  • 67
19
votes
4 answers

What is the most effective way to create BigInteger instance from int value?

I have a method (in 3rd-party library) with BigInteger parameter: public void setValue (BigInteger value) { ... } I don't need 'all its power', I only need to work with integers. So, how can I pass integers to this method? My solution is to get…
Roman
  • 64,384
  • 92
  • 238
  • 332
19
votes
3 answers

How do you convert A binary number to a BigInteger in Java?

I needed to convert a very big binary value into its decimal equivalent. As it is a big integer I was using BigInteger. So how do I convert this binary number to a BigInteger?
Daanish
  • 1,061
  • 7
  • 18
  • 29
18
votes
2 answers

Arbitrary-Precision Math in PHP

I'm currently trying to figure out how to work with arbitrary-precision numbers in PHP. So I guess my first question would be what exactly is arbitrary-precision math. I tried Googling for a good definition but for some reason nobody can put it in…
parent5446
  • 898
  • 7
  • 17
18
votes
8 answers

Decimals and commas when entering a number into a Ruby on Rails form

What's the best Ruby/Rails way to allow users to use decimals or commas when entering a number into a form? In other words, I would like the user be able to enter 2,000.99 and not get 2.00 in my database. Is there a best practice for this? Does gsub…
James
  • 181
  • 1
  • 1
  • 3
18
votes
2 answers

Hex to int C# with VERY big numbers

I have a 256 chars long string that contains a hex…
Fredefl
  • 1,391
  • 2
  • 17
  • 33
18
votes
1 answer

Is there a numpy biginteger?

Hmm. There doesn't seem to me a way to store Python's bigintegers in a numpy array. Is there something special you have to do, to declare a numpy array with bigints?
Jason S
  • 184,598
  • 164
  • 608
  • 970
18
votes
4 answers

How much space does BigInteger use?

How many bytes of memory does a BigInteger object use in general ?
Nikunj Banka
  • 11,117
  • 16
  • 74
  • 112
18
votes
4 answers

Sum a list of BigIntegers

I've looked all over but can't figure this out. How do you sum a list of BigIntegers? Using System.Numerics; Using System.Linq; List bigInts = new List(); BigInteger sum = bigInts.Sum(); // doesn't…
jb.
  • 9,921
  • 12
  • 54
  • 90
17
votes
7 answers

php: int() function equivalent for bigint type? (int() cuts strings to 2147483647)

php: What's the equivalent int() function for bigint type? (int() cuts big numbers to 2147483647)? Example: $bigint1="12312342306A_C243"; $bigint1=(int)$bigint1;//2147483647 but I want it to be 12312342306.
Haradzieniec
  • 9,086
  • 31
  • 117
  • 212
17
votes
2 answers

Is there a BigInteger class in PHP?

Is there a BigInteger class in PHP? If so, how do I access it or use it?
freddiefujiwara
  • 57,041
  • 28
  • 76
  • 106
17
votes
3 answers

How to Serialize BigIntegerField, TextField in serializer Django

I have a model which has following attributes from django.db import models class ApiLogs(models.Model): user_id = models.BigIntegerField(null=True) ip = models.CharField(max_length=16) user_agent = models.TextField(blank=True,…
17
votes
3 answers

practical BigNum AVX/SSE possible?

SSE/AVX registers could be viewed as integer or floating point BigNums. That is, one could neglect that there exist lanes at all. Does there exist an easy way to exploit this point of view and use these registers as BigNums either singly or…
user1095108
  • 14,119
  • 9
  • 58
  • 116
17
votes
7 answers

How can I generate a random BigInteger within a certain range?

Consider this method that works well: public static bool mightBePrime(int N) { BigInteger a = rGen.Next (1, N-1); return modExp (a, N - 1, N) == 1; } Now, in order to fulfill a requirement of the class I'm taking, mightBePrime must accept a…
Trevor Dixon
  • 23,216
  • 12
  • 72
  • 109