Hi,
In the following sample (and useless) code fragment:
#include <bcconfig.h>
#include <BigNumber.h>
#include <number.h>
void setup()
{
BigNumber x;
BigNumber y (2);
BigNumber z (2);
BigNumber a;
a = x/y;
a = sqrt(x);
x = a.powMod (y, z);
}
void loop()
{
}
the function powMod generates this error:
sketch_aug03a:15: error: ‘class BigNumber’ has no member named ‘powMod’.
Please note this is a test fragment only. It is not meant to run.
Looking at Bignum .h and Bignum.cpp there seems to be a function powMod
BigNumber.h:
// raise number by power, modulus modulus
BigNumber powMod (const BigNumber power, const BigNumber & modulus) const;
BigNumber.cpp:
// raise number by power, modulus modulus
BigNumber BigNumber::powMod (const BigNumber power, const BigNumber & modulus) const
{
BigNumber result;
bc_raisemod (num_, power.num_, modulus.num_, &result.num_, scale_);
return result;
}
This question is derived from a post by Nick Gammon on his site:
Gammon Forum : Electronics : Microprocessors : Arduino generating prime numbers.
See the post and the code posted Fri 29 Nov 2013 at 11:42PM (UTC). I am trying to use this code which generates huge prime numbers and uses BigNumbers.
There is this function Miller:
bool Miller(BigNumber source, int certainty)
{
if (source == 2 || source == 3)
return true;
if (source < two || source % two == 0)
return false;
BigNumber d = source - one;
int s = 0;
while(d % two == 0)
{
d /= two;
s += one;
}
BigNumber a;
for(int i = 0; i < certainty; i++)
{
do
{
rng (a);
}
while(a < two || a >= source - two);
BigNumber x = a.powMod (d, source);
if(x == one || x == source - one)
continue;
for(int r = 1; r < s; r++)
{
x = x.powMod(two, source);
if(x == one)
return false;
if(x == source - one)
break;
}
if(x != source - one)
return false;
}
return true;
} // end of Miller
which also fails to compile for the same reason. It is something I have missed I am sure as I trust this code source.
What am I missing?
Regards, Fred.