Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Negative exponents using the BigInteger class

I'm doing some maths using the Java BigInteger class but getting an error when I'm trying to use a negative number as an exponent. Am I right in thinking that you can rearrange:

b · φ(N)^−1 mod N

as:

      b
------------
φ(N)^1 mod N

If not how can I rearrange the expression as to not get a negative exponent error in my Java code?

like image 571
W.Howe Avatar asked Oct 28 '25 03:10

W.Howe


1 Answers

BigInteger can't have negative exponents, because that would make it a fraction (1 over something), which is not an "integer".

Try using BigDecimal instead.

As for your rearrangement of the expression, it should be rearranged like this:

      b
------------  mod N
   φ(N)^1
like image 176
Sweeper Avatar answered Oct 29 '25 19:10

Sweeper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!