Questions tagged [gmp]
The GNU Multiple-Precision Library (GMP) is a mature, free library for arbitrary-precision arithmetic with support for big signed integers, rational numbers, and floating point numbers. The basic interface is for C but wrappers exist for other languages including Ada, C++, C#, OCaml, Perl, PHP, and Python. It is distributed under the GNU LGPL and is used for cryptography applications and in computer algebra systems such as Mathematica and Maple.
1,046
questions
0
votes
0
answers
25
views
How do I format mpf_set_str() with exponents for GMP?
If this code weren't so mature I'd think GMP may be buggy here.
The doc here https://gmplib.org/manual/Assigning-Floats says:
Function: int mpf_set_str (mpf_t rop, const char *str, int base)
Set the ...
0
votes
0
answers
12
views
Undefined symbols for architecture arm64 when linking GMP library in C++ project on Mac M1 in CLion, clang: linked command failed [duplicate]
I’m developing a C++ project using the SymEngine library with GMP dependencies on a Mac M1, and I’m encountering the following linker errors for architecture arm64:
Undefined symbols for architecture ...
0
votes
1
answer
25
views
What is the hard and fast rule for GMP mpf precision to number of significant digits
GMP currently works out of the box with a precision of 64 precision bits (I think that's what mp_bitcnt_t is called).
For me this works up to numbers of value up to around 1x10e-22 I think (where I'm ...
1
vote
1
answer
42
views
Pass out an array of char* into Swift from C
To be clear I want to send my C function an array of null strings of fixed length like:
["\0\0\0\0\0\0", "\0\0\0\0\0\0", "\0\0\0\0\0\0"]
expect the array to return ...
-4
votes
1
answer
57
views
golang chan sender and receive queue sequence question
here is my code , why the answer is not sequence. GOMAXPROCS is 1 , and I'm confused why the first person to receive the message is the last Goroutine to join the queue !
I know in P > 1 example ,...
0
votes
1
answer
34
views
SIGSEGV with with MPZ_Class and acutest
I am new to c++ programming and to improve I wanted to make an implementation of the bleichenbacher attack. I have prior built one in python and thought it would make a good exercise to learn c++ a ...
0
votes
1
answer
36
views
SWIG, Python-C++ and GMP – Passing an int type argument to a function in the SWIG-generated shared library that accepts an mpz_class type argument
I'm trying to implement a wrapper for running a fermat-factorization test on a public key. I've generated the shared library successfully using SWIG:
fermat.h:
#ifndef FERMAT_H
#define FERMAT_H
#...
3
votes
1
answer
137
views
Can AVX-512 be used to calculate the multiplication of two 256-bit Integers on a 64 bit computer in C++? Whether using Assembly Language or not
Regarding arbitrary precision arithmetic: Can AVX-512 be used to calculate the multiplication of two 256-bit Integers on a 64-bit computer in C++?
Is there an intrinsic Integer data type of 512 bits ...
1
vote
1
answer
63
views
Different result in JS & PHP because of different integer range
<script>
function hs(e, n) {
return e * n % e;
}
alert(hs(1752865668, 1716717484170));
//result: 1752622684
</script>
<?php
function hs($e, $n) {
return $e * $n % $e;
}
echo ...
0
votes
1
answer
81
views
GMP for C++: more troubles with `auto`
Here are more about strange behaviour of GMP C++ Class Interface, related to the C++ auto keyword. My previous question was also about this keyword, and its removal solved my problem. However it was ...
2
votes
0
answers
24
views
Initializing an mpz_t variable with a static function in between translation units
I am writing a cryptographic program for my bachelor's. I've been uzing an mpz_t variable for exponentiation with the PBC library.
Currently, to avoid running mpz_init on every exponentiation, I only ...
4
votes
1
answer
53
views
Segmentation faults and memory leaks while calling GMP C functions from Python
Work was quiet today, and so the team was directed to do some "self-development". I decided to have some fun calling C functions from Python. I had already had a good time using Rust to ...
1
vote
1
answer
45
views
GMP library for C++: converting `mpz_class` to `unsigned long`
My first experience with GMP big integers... The simple test below can't be compiled because the get_ui member function is not found. The function get_ui is mentioned in the GMP manual.
#include <...
0
votes
0
answers
60
views
gmp_mod Argument #1 ($num1) is not an integer string Hashids package
I'm using the latest version of Hashids in my Laravel 11 project running PHP 8.3 and have stumbled upon an issue, given the following, which is a numeric string:
(new Hashids('', 7))->encode('...
1
vote
2
answers
751
views
How can I use CMake's FetchContent_Declare feature to automatically download and integrate the GMP library into my project?
I'm having trouble integrating the GMP library into my CMake project. Specifically, I'm struggling to configure CMake to automatically download and include GMP using FetchContent_Declare. I'm unsure ...