FAQ Database Discussion Community

I have the following issue: when trying to add to a sum of BigIntegers the outcome remains 0. Here is the code: public void NumberOfOutcomes(int x, int y){ BigInteger first = BigInteger.valueOf(0); BigInteger second = BigInteger.valueOf(0); for(int i = 0; i <= (x / 2); i++){ first.add( fac(x - i).divide((fac(x...

## Find integer part of nth root

c#,math,binary-search,biginteger,newtons-method
I have implemented a class for Big Integer in c# (project for school) , and I have to calculate nth root. I tried binary seach but it is taking too long for very big integers. I also tried to implement Newton method. The problem is that my Division function return...

## using biginteger for java program regarding virtual addresses

java,virtual,biginteger
Maybe I'm misunderstanding due to my limited use of biginteger, but I have a program that needs to take user input for page size and virtual address and calculate offset and virtual page. I can do the calculation no problem, but when comparing itegers for the input, the necessary value...

## Print 2^64 integer in c++

c++,biginteger
I was solving a programming problem in c++. And the problem said that The input numbers are not greater than 2^64. How can I work with that big number in c++? I have to use subtraction with the number also....

## Fibonacci with huge numbers in c#

c#,.net,stack-overflow,biginteger,fibonacci
I`m trying to find the first fib number to contain 1000 digits. Because i have no data-type capeable of holding such a number, i created a class called hugeNumber which holds the digits in a list, with a decimal base. I get a stack overflow at the generation of the...

## No autoboxing for BigInteger?

java,biginteger,autoboxing
While fixing the code for this question, I realized that autoboxing doesn't work for all types. This code compiles: Integer y = 3; But doing the same with BigInteger doesn't compile: BigInteger x = 3; -> "Type mismatch: cannot convert from int to BigInteger" Is there no autoboxing for BigInteger?...

## Decryption with RSACryptoServiceProvider fails

c#,encryption,key,rsa,biginteger
I want to decrypt a byte array. to do this, I encrypt the data in java with the servers public key. Then I send the data to the c# server. There I want to decrypt with the "RSACryptoServiceProvider" class. I initialize it with: RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024); rsa.ImportParameters(keyInfo); The...

## Java pow BigInteger implementation

java,cryptography,biginteger,pow,exponent
I am working on a cryptography implementation and part of the design includes the following: ( (y^a)^b / (y^c)^b ) mod p I have the following snippet: BigInteger yab = y.pow(ab.intValue()); BigInteger ycb = y.pow(cb.intValue()); BigInteger ans = (yab.divide(ycb)).mod(p); It works fine for small integer. Once I replaced it with...

## How to assign a very large number to BigInteger?

java,biginteger,value-of
Given the following input: 4534534534564657652349234230947234723947234234823048230957349573209483057 12324000123123 I have attempted to assign these values to BigInteger in the following way. public static void main(String[] args) { Scanner sc = new Scanner(System.in); BigInteger num1 = BigInteger.valueOf(sc.nextLong()); sc.nextLine(); BigInteger num2 = BigInteger.valueOf(sc.nextLong()); BigInteger additionTotal = num1.add(num2); BigInteger multiplyTotal = num1.multiply(num2); System.out.println(additionTotal);...

## Why isn't BigInteger a primitive

java,biginteger,primitive
If you use BigInteger (or BigDecimal) and want to perform arithmetic on them, you have to use the methods add or subtract, for example. This may sound fine until you realize that this i += d + p + y; would be written like this for a BigInteger: i =...

## MySQL / MariaDB unique BLOB of fixed length

I need a 16-byte binary data column to be unique. Why can't a BLOB(16) be unique in MySQL and MariaDB, when it supports unique VARCHAR? That this is supported but not a fixed-length set of bytes seems nuts. Also, it's not acceptable to waste space by storing a binary value...

## How to convert equation from long to Biginteger

java,biginteger
So I am doing this problem which requires to calculate the equations. At first i thought long would be enough for the range but now it has exceeded the long range and now i have to use BigInteger. I have to convert one equation but I haven't been able to...

## Why (c++) casting from long long unsigned int to long double and back produces 0

c++,casting,biginteger
I have such program: #include "stdafx.h" #include <iostream> using namespace System; using namespace std; typedef long long unsigned int T_num; typedef long double T_ld; int main(array<System::String ^> ^args) { T_num a = numeric_limits<T_num>::max(); T_ld b = numeric_limits<T_ld>::max(); if ( b > a ) { cout << "decimal is bigger than...

## RSA turning string to BigInteger [closed]

java,rsa,biginteger
I am playing around with an RSA Algorithm program and trying to make it accept a string as the message instead of a number. I thought I had the conversion right but I get an error when I run, can anyone see why? import java.math.BigInteger; import java.security.SecureRandom; public class rsa...

## Reverse Multiplication

java,math,biginteger,modulus
I have the following number; let's call it number one -1757151608 then I have a second number, let's call it unknown 94507795 and finally, I have the product, let's call it number two -1000 If I multiply the first two numbers in form, I get the answer as -1000. Problem...

## Non-matching values for modulus and p*q in RSA encryption

c#,encryption,encoding,biginteger,multiplication
I am currently doing a cryptography project which involves RSA encryption. I used the RSACryptoServiceProvider class to generate the values p, q and n (modulus). Since n = pq, I decided to test if the two values (i.e. pq and n) match. When I used the BigInteger class to multiply...

## Why size of 'BigInteger' differs when saved from what 'bitLength' reports?

java,biginteger
I have a variable named out that is a BigInteger. When trying to get the length of this variable in bits using out.bitLength(); I receive 46. If I save this in file using ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("./testBig.dat")); oos.writeObject(out); oos.close(); I get a file that is 208 bytes. Can...

## Modifying bigInteger after dividing Java

java,biginteger
I've looked a lot through here and can't quite find why this line is wrong: ArrayList <BigInteger> data = new ArrayList(); int [] primes = new int; ... // Some initializing ... data.get(i) = data.get(i).divide( BigInteger.valueOf( primes[place] ) ); //<---- ... // Rest of the code Required: variable; Found: value.....

## Catch/try not working for input mismatch exception with scanner?

java,java.util.scanner,biginteger,inputmismatchexception
Alright so I'm taking a CS security class that has some basic java programing in it and our first assignment is to play with BigInteger. However, we also have to "bullet proof" our program. And while my method isn't the most ideal, it works EXCEPT for the first input. Aka...

## Java Fermat Factorisation algorithm BigInteger not working

java,algorithm,biginteger
I'm implementing Fermat Factorization algorithm using BigInteger so I can factor. But at the moment, the code is not working; it hangs for some reason. Could someone direct me to where the issue is, or let me know if my algorithm is incorrect? BigInteger makes life difficult, so I had...

## Golang overflows int64

go,biginteger,int64
I try to use this code, but gives me an error: constant 100000000000000000000000 overflows int64 How can I fix that ? // Initialise big numbers with small numbers count, one := big.NewInt(100000000000000000000000), big.NewInt(1) ...

## BigInteger implementation of RSA's key generation

java,rsa,biginteger
I am having a bit of trouble getting the modulus's size to be consistently 128 bytes big. Sometimes the modulus's byte array has a size of 129 or even 130. I've searched for implementation online, and my implementation is really close to the one from this link: http://introcs.cs.princeton.edu/java/78crypto/RSA.java.html Here is...

## Converting from a char to a long

java,arrays,long-integer,biginteger
I'm creating a big integer class. I read in two longs as function arguments and what I want to do is have each number in the long read in to occupy one index of an array. I've done this by converting the long into a string then char array and...

## Big integer in Forth?

biginteger,forth,gforth
I have developed a big-integer system (for numbers of dynamical length) in Forth (ANS-94), but it is too slow. Are there any fast systems available? Also, any tip regarding the subject is welcome....

## Why is my program not giving the expected output?

java,arraylist,biginteger
I am working on problem 29 of Project Euler which states: Consider all integer combinations of a^b for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 2^2=4, 2^3=8, 2^4=16, 2^5=32 3^2=9, 3^3=27, 3^4=81, 3^5=243 4^2=16, 4^3=64, 4^4=256, 4^5=1024 5^2=25, 5^3=125, 5^4=625, 5^5=3125 If they are then placed...

## Is there a numpy biginteger?

python,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?

## Language for working on big numbers

biginteger
I am working on a task that consists different operations on very big numbers. Example : Multiplying two 50 digit numbers. That big-sized numbers cannot be handled using C. Can someone suggest me some programming language that can handle operations on such types of big numbers without using any special...

## Postgres maximum value for BIGINT

postgresql,types,biginteger
Is it possible to get the maximum value for BIGINT type without hardcoding it? I know that the limit is well known, however I wouldn't like to hardcode it....

## computing prime factors using same code produces different results?

f#,primes,biginteger
I am basically trying to compute the factors of a BigInteger that are a prime, I have two simple factorization functions, they both look like they should produce the same result in the way I used them here down below but this is not the case here, can someone explain...

## Converting a hex string to its BigInteger equivalent negates the value

c#,biginteger
I have a string which represents a large hexadecimal number which I want to convert to an integer. When I try to convert though, the answer for the integer equivalent is negative. Here's the code: string hex = "9782E78F1636"; BigInteger b1 = BigInteger.Parse(hex, NumberStyles.AllowHexSpecifier); How can I get the correct...

## Is there a way to get the total size of a 'BigInteger' variable?

java,biginteger
I would like to be able to tell how big in bits is a variable of type BigInteger in my program. Is this possible?...