Re: Modular exponentiations in bc



On Thu, 17 Apr 2008 22:28:26 +0000, Dances With Crows wrote:

K. Jennings staggered into the Black Sun and said:
I would be interested to compute modular exponentiations in bc. One
can't use a^b % c for arbitrarily large a, b and c, for bc seems to
carry out this computation in the straightforward way: First compute
a^b and then reduce the result mod c. There is no way to compute a^b in
a reasonable time (or store the result) when a and b are large enough.

Looking into the bc 1.06 sources, a function called bc_raisemod() is
defined that seems to do what I need - however, I have no clue as to
how to invoke it from the bc command line. Ideas, anyone?

I looked at the source and I *think* the operator you want is | .
According to eval.c, this operator calls dc_modexp(), which calls
bc_raisemod() . I don't know for sure whether it will work according to
what you want. (All the math I need can be handled by normal operators,
which is nice.)

Thanks for your feedback. Alas, the | operator is not mentioned
in bc's doc, and all my attempts to get bc to recognize it have so far
failed.

However, it can be used all right from dc.

.



Relevant Pages

  • Re: DES.CreateEncryptor() Question
    ... ciphers are publicly available. ... You can look at the alogorithm's math and know exactly what it's doing. ... the key is used as part of the math to encrypt the data. ... it's used in various Feedback modes. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Woman steals 1997 dissertation
    ... >>> happens all the time (alas) that people get PhD's in math ... >>> at that age or older. ... > My guess is that David is not bemoaning the simple proposition ...
    (sci.math)
  • Re: manipulating hex values
    ... and perform math on it. ... Int32.ToStringmethod to translate it back. ... Alas, I'm finding that subtle color shifting really isn't best handled by ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Set Theory, Anyone?
    ... Then stop taking math; and it's now obvious why you are unethical and ... lazy. ... Must be a plus in your intended profession, alas. ...
    (sci.math)
  • Re: Math needed for "Algorithms"
    ... next semester and wondered what math I should brush up on to ... ago, so I'm somewhat rusty. ... any feedback is appreciated. ... No sweat. ...
    (comp.programming)