📄 testgmp.cpp
字号:
// testgmp.cpp// stand-alone test of GMP; not very thorough, as it is really// intended just to verify GMP is installed right. more extensive// tests are in selgamal.cpp and sdsa.cpp#include "gmp.h" // GMP functions#include <stdio.h> // printfint main(){ printf("beginning of main\n"); mpz_t x, y, z, zero; mpz_init(x); mpz_init(y); mpz_init(z); mpz_init(zero); mpz_add_ui(x, zero, 30); if (mpz_get_ui(x) != 30) { printf("mpz_add_ui or mpz_get_ui doesn't work\n"); return 4; } mpz_add_ui(y, zero, 7); mpz_add(z, x, y); if (mpz_get_ui(z) != 37) { printf("mpz_add doesn't work\n"); return 4; } if (mpz_invert(x, y, z)==0) { // y = inverse of 7 (mod 37), should be 16 printf("mpz_invert doesn't work (claims no inverse exists)\n"); return 4; } unsigned ux = mpz_get_ui(x); printf("inverse of 7 (mod 37) is %u\n", ux); if (ux != 16) { printf("mpz_invert doesn't work\n"); return 4; } mpz_clear(x); mpz_clear(y); mpz_clear(z); mpz_clear(zero); printf("end of main\n"); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -