fix type & cast
This commit is contained in:
parent
9960fe3fe8
commit
802d8294db
@ -264,7 +264,7 @@ int main(void)
|
|||||||
// test mp_get_int
|
// test mp_get_int
|
||||||
printf("\n\nTesting: mp_get_int");
|
printf("\n\nTesting: mp_get_int");
|
||||||
for (i = 0; i < 1000; ++i) {
|
for (i = 0; i < 1000; ++i) {
|
||||||
t = ((unsigned long) rand() * rand() + 1) & 0xFFFFFFFFuL;
|
t = (unsigned long)(rand() * rand() + 1) & 0xFFFFFFFFuL;
|
||||||
mp_set_int(&a, t);
|
mp_set_int(&a, t);
|
||||||
if (t != mp_get_int(&a)) {
|
if (t != mp_get_int(&a)) {
|
||||||
printf("\nmp_get_int() bad result!");
|
printf("\nmp_get_int() bad result!");
|
||||||
|
@ -34,14 +34,14 @@ static void draw(mp_int *a)
|
|||||||
|
|
||||||
static unsigned long lfsr = 0xAAAAAAAAuL;
|
static unsigned long lfsr = 0xAAAAAAAAuL;
|
||||||
|
|
||||||
static int lbit(void)
|
static unsigned int lbit(void)
|
||||||
{
|
{
|
||||||
if ((lfsr & 0x80000000uL) != 0uL) {
|
if ((lfsr & 0x80000000uL) != 0uL) {
|
||||||
lfsr = ((lfsr << 1) ^ 0x8000001BuL) & 0xFFFFFFFFuL;
|
lfsr = ((lfsr << 1) ^ 0x8000001BuL) & 0xFFFFFFFFuL;
|
||||||
return 1;
|
return 1u;
|
||||||
} else {
|
} else {
|
||||||
lfsr <<= 1;
|
lfsr <<= 1;
|
||||||
return 0;
|
return 0u;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ static int sizes[] = {256, 512, 768, 1024, 1536, 2048, 3072, 4096};
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
char buf[2000];
|
char buf[2000];
|
||||||
int x, y;
|
size_t x;
|
||||||
|
int y;
|
||||||
mp_int q, p;
|
mp_int q, p;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
clock_t t1;
|
clock_t t1;
|
||||||
@ -17,7 +18,7 @@ int main(void)
|
|||||||
|
|
||||||
out = fopen("2kprime.1", "w");
|
out = fopen("2kprime.1", "w");
|
||||||
if (out != NULL) {
|
if (out != NULL) {
|
||||||
for (x = 0; x < (int)(sizeof(sizes) / sizeof(sizes[0])); x++) {
|
for (x = 0; x < (sizeof(sizes) / sizeof(sizes[0])); x++) {
|
||||||
top:
|
top:
|
||||||
mp_2expt(&q, sizes[x]);
|
mp_2expt(&q, sizes[x]);
|
||||||
mp_add_d(&q, 3uL, &q);
|
mp_add_d(&q, 3uL, &q);
|
||||||
|
@ -21,7 +21,7 @@ static int is_mersenne(long s, int *pp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* n = 2^s - 1 */
|
/* n = 2^s - 1 */
|
||||||
if ((res = mp_2expt(&n, s)) != MP_OKAY) {
|
if ((res = mp_2expt(&n, (int)s)) != MP_OKAY) {
|
||||||
goto LBL_MU;
|
goto LBL_MU;
|
||||||
}
|
}
|
||||||
if ((res = mp_sub_d(&n, 1uL, &n)) != MP_OKAY) {
|
if ((res = mp_sub_d(&n, 1uL, &n)) != MP_OKAY) {
|
||||||
|
@ -6,14 +6,14 @@ int main(void)
|
|||||||
{
|
{
|
||||||
mp_int modulus, R, p, pp;
|
mp_int modulus, R, p, pp;
|
||||||
mp_digit mp;
|
mp_digit mp;
|
||||||
long x, y;
|
int x, y;
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
mp_init_multi(&modulus, &R, &p, &pp, NULL);
|
mp_init_multi(&modulus, &R, &p, &pp, NULL);
|
||||||
|
|
||||||
/* loop through various sizes */
|
/* loop through various sizes */
|
||||||
for (x = 4; x < 256; x++) {
|
for (x = 4; x < 256; x++) {
|
||||||
printf("DIGITS == %3ld...", x);
|
printf("DIGITS == %3d...", x);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
/* make up the odd modulus */
|
/* make up the odd modulus */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user