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
0
votes
1 answer

c# BigInteger to 32 byte hex

I need to get from a biginteger to a 32 byte hex value. To use in the third parameter on this description: My current code is not generating a valid hex value. public static string GetTargetHex(BigInteger difficulty) { // 2^256 / difficulty. …
Erik
  • 417
  • 4
  • 14
0
votes
1 answer

I need a mutable version of BigInteger, but I can't access mutablebiginteger

I'm doing an article right now about code I wrote. I'm calculating values that go past the limit of the variable long and I also need to compare this values, so I'm using BigInteger instead. The thing is, BigInteger is immutable so every time a new…
0
votes
3 answers

Using logarithm instead of division for large numbers?

I couldn't really come up with a proper title for my question but allow me to present my case; I want to calculate a significance ratio in the form: p = 1 - X / Y Here X comes from an iterative process; the process takes a large number of steps and…
posdef
  • 6,498
  • 11
  • 46
  • 94
0
votes
1 answer

Converting very large decimal numbers to hexadecimal in swift

We can use String Format specifier to convert an integer value or a long value to hexadecimal notation. Int Example: print(String(format:"%x", 1111)) //result:457 Long Example: print(String(format:"%lx",…
KingHodor
  • 537
  • 4
  • 17
0
votes
1 answer

Why aren't the bigInts adding?

I made a NodeJS program that takes pairs of integers (m, n) as input and prints the sum of their factorials (facm, factn) on the console. I used the BigInteger.js library so that I can calculate using big numbers. But when I input 20 1, the program…
zadspecial
  • 13
  • 3
0
votes
1 answer

As of 2018, is there any performance difference by using bigint instead of int as a primary key in Postgres?

I want to have random primary keys in many of my tables (users table, posts table, etc...) just like the design of medium.com (have a look at the article id in the url or in the apis, it's a 12 random hex chars string that most probably corresponds…
pls no
  • 129
  • 1
  • 3
0
votes
2 answers

How to parse a binary string to a binary literal in C#

Here is my specific problem. I need to represent an integer (like 1,2,3,..) as a binary literal with exactly 128 bits. This is my string representing 1 in binary: string = "000...0001"; // 128 characters. all zeros until the last 1 Intended…
jburcham
  • 1
  • 1
0
votes
1 answer

'Big' fractions in Julia

I've run across a little problem when trying to solve a Project Euler problem in Julia. I've basically written a recursive function which produces fractions with increasingly large numerators and denominators. I don't want to post the code for…
Mark Birtwistle
  • 362
  • 2
  • 10
0
votes
2 answers

Making a copy of a BigInteger

As part of one of my university assignments I've been asked to code the RSA algorithm to encrypt a user message. My encryption code is here: BigInteger byte_message = new BigInteger(user_message.getBytes()); BigInteger encrypted_message =…
0
votes
1 answer

How to create generic method that acts differently depending on the T?

What is the best way to create a generic method that acts differently depending on the given type without using if statements that check what type is that? For instance, how to create an Add(T x, T y) method that returns x + y if T is Integer and…
0
votes
4 answers

BigInteger Homework Help Needed

I have been told I have to write a BigInteger class, I know there is one, but I have to write my own. I am to take either ints or a string and turn them into arrays to store them. From there I am to then allow adding, subtract, and multiplying of…
Tempus35
  • 176
  • 3
  • 13
0
votes
1 answer

How to convert a double value to big integer or long value

Need to convert a double value to big integer or long value. tried with big integer but the converted value differs from original value. double doub = 123456789123456789123456789d; BigDecimal bd =…
Heisenberg
  • 147
  • 1
  • 4
  • 14
0
votes
1 answer

How to convert decrypted BigInteger back to string?

I am working on an RSA encryption and I can properly encrypt and decrypt a BigInteger. The issue that I am having is that before the encryption I can easily convert the BigInteger back into the original string. However, after encrypting and then…
Ras
  • 5
  • 1
0
votes
1 answer

How do you encrypt a string with BigInteger?

I am attempting to take an alphanumeric string and encrypt it using big integer. My encryption and decryption work when I initialize BigInteger with a decimal value, such as 10. However when I initialize BigInteger using a string the decryption does…
Ras
  • 5
  • 1
0
votes
1 answer

DSA Signature Verification and BigInteger class

I have been given a (very) simple DSA problem, and have already found the key and other variables. To verify the signature I need to somehow translate the equation: V = [(y^u1*h^u2)mod p] mod q into a BigInteger operation. Is this even possible on…