Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
lifg
Dec 4, 2000
<this tag left blank>
Muldoon
I'm new to go, and having trouble with math/big. I'm creating lots of equations, but math/big uses all methods, no functions, so my code is looking hellish.

Like, I want to do this:

code:
(y**2 - x**3 - 7) % p
But I need big/Int. I'd like to do be able to use it like this:

code:
big.Mod(big.Sub( big.Sub( big.Exp(y,2,nil), big.Exp(x,3,nil)), 7), p)
But since big.Int uses methods, I'm creating code that looks like this:

code:
a := new(big.Int).Set(y)
b := new(big.Int).Set(x)
a.Exp(a, big.NewInt(2), nil)
b.Exp(b, big.NewInt(3), nil)
a.Sub(a, b)
a.Sub(a, big.NewInt(7))
a.Mod(a, p)
And that looks ugly to me.

Am I doing this right?

Adbot
ADBOT LOVES YOU

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
Thanks. I’ll play around with using a receiver like that, but maybe you’re right and I’ll stick with what I have.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply