- 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?
|
#
¿
Aug 12, 2021 19:50
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 12, 2024 05:13
|
|
- 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.
|
#
¿
Aug 14, 2021 21:28
|
|