Skip to content

Tag: biginteger

How do I prevent a long overflow?

My assignment ask us to ask the user to enter a number and print the factorial of it, it also ask us to not allow the user to chose any negative number or number over 25, when they do, we loop them back to scanner to re renter a number we were also told to store the number in a

Something wrong with BigInteger

when i test this function with base16 :F0F0F0F0F0F0F0, it return right result = 67818912035696880 BUT when i test with base16: F0F0F0F0F0F0F0F0, it returns wrong result: 17361641481138401580 which right result must be 17361641481138401520 please help me! Answer Math.pow delivers a double, 8 bytes. So from som…

Is there a way to pow 2 BigInteger Numbers in java?

I have to pow a bigInteger number with another BigInteger number. Unfortunately, only one BigInteger.pow(int) is allowed. I have no clue on how I can solve this problem. Answer I have to pow a bigInteger number with another BigInteger number. No, you don’t. You read a crypto spec and it seemed to say th…

BigInteger.intValue() equivalent in C#

I am trying to translate a java code into C# and encountered a problem working with BigInteger operations. I found several resources on BigInteger implementation in C# and the intValue itself. But no clue on BigInteger.intValue equivalent in C#. The definition in Java is: Converts this BigInteger to an int. T…

Java BigInteger alternative

Is there a way to improve BigInteger performance with caching? When you operate on BigInteger it always creates a new BigInteger. For example, when you multiply two big integers, a new BigInteger is created to host the result. I want to use some mutable version of a BigInteger that will update one of the fiel…

Fibonacci calculator with BigIntegers

I’m working on a homework project where I must have the user input a number, and the computer spits out the Fibonacci numbers up to that one. I’d normally be able to do this, with int values, except that for this program, I need to use the BigInteger type instead, because int, long, double, etc. t…