2,006 questions
Best practices
3 votes
6 replies
142 views
Avoiding array duplication in big integer routine
I am working on a multiplication routine in a big integer library in POSIX C99 with a signature of bigint_st *bigint_mul(bigint_st *dest, const bigint_st *a, const bigint_st *b). Many of the routines ...
1 vote
2 answers
108 views
How to parse JSON values with large numbers using zod?
Is it possible to parse a JSON string like '{id: 3458764513820541000}' using zod without resorting to an additional library like json-bigint?
0 votes
0 answers
51 views
How to manage c# BigInteger on MongoDB
I'm trying to manage BigInteger on MongoDB. I did a test, but it doesn't seem to work correctly. It is supposed to have the following poco: public class Poco { public string MyString { get; set; } =...
2 votes
0 answers
240 views
Is Karatsuba algorithm necessary?
I am developing an algorithm that multiplies large numbers. I am doing LeftLength x RightLength multiplications. Karatsuba algorithm does less multiplications. Currently, the algorithm is more ...
0 votes
0 answers
90 views
vb.net BigInteger and ensuring that values are read correctly
Private Sub routine() Dim bytes() As Byte Dim n As BigInteger = 1 Dim s As Integer = 1 If System.IO.File.Exists("resources.bin") Then Dim fs2 = New IO.FileStream(&...
1 vote
0 answers
69 views
Why aren't there operator overloads for working with BigInteger and BigDecimal as part of the BigInteger and BigDecimal class imports?
...such as infix operator fun BigInteger.plus(other: Int) = this + other.toBigInteger() infix operator fun Int.plus(other: BigInteger) = toBigInteger() + other infix operator fun BigInteger....
0 votes
0 answers
145 views
Question about Knuth's Algorithm D for division
I want to implement Knuth's Algorithm D for division on C (Link to Knuth's book, p272). In step "D4. [Multiply and subtract.]", it states: if the result of this step is actually negative, (...
0 votes
1 answer
102 views
How do I convert hexidecimal to decimal using C# & BigInt?
I can reproduce this 1 line all the time & I'm thrown off why .Net 8 x64 is converting to a negative decimal. BigIntegers have to be used because of the hex sizes. Conversion URL fact checking ....
0 votes
0 answers
110 views
The fastest MOD algorithm in C++ for extremely large uint_64_t numbers stored in an array
I am working with extremely large numbers and would like to verify my Karatsuba multiplication result ((2^136279841)-1)^2 which needs (532 344 * _m256i_epi64)^2 i.e. 4,258,752 uint64_t to store the ...
1 vote
1 answer
125 views
Bug in the normalization step of Knuth Algorithm D (TAOCP 4.3.1)?
Knuth Algorithm D, during the normalization step (D1), states to set d to (b-1)//v_hi where b is the basis (word size or half-word size) and v_hi is the upper limb of the denominator. Then multiply ...
1 vote
1 answer
81 views
Bounds for C# Generic Random Array Generator
I have written this block of code, in an attempt to create a generic random array generator (quite an interesting approach, if I must say so myself) public unsafe class RandomArray<T> : ...
1 vote
1 answer
226 views
Find n-element in sequence. How to speed up the programm (time) for n > 10^6?
I think I have right algorithm, but when the values increase to 106 and more, I exceed the MEMORY or TIMELIMIT allowed. At first I tried to push the elements to a vector, then I changed the method to ...
5 votes
1 answer
183 views
Time complexity of this dynamic programming algorithm to get nth fibonacci number
I'm confused about the time complexity of this algorithm: function fib(n) if n = 0 return 0 else var previousFib := 0, currentFib := 1 repeat n − 1 times // loop is ...
1 vote
1 answer
406 views
Enforce the use of Utf8JsonReader.ValueSequence for test purposes
I wrote my own BigIntegerConverter for JSON serialization/deserialization (.Net System.Text.Json) In the Read method I checked if ValueSequence is used ... string stringValue; if (reader....
1 vote
0 answers
158 views
Why does `BigInt(n)` return a different integer than `n`? [duplicate]
JavaScript's number can represent 18446744073709552000: > n = '18446744073709552000' > Number(n) 18446744073709552000 > String(Number(n)) === n true So I would expect BigInt(...