15,353,818 members
1.00/5 (1 vote)
See more:
I don't know the Java language. I am getting error with the code below on .Net. I know that the Biginteger process is also in Java, but I could not convert my vb.net codes to Java codes. I'm wondering if I will get the same error in Java. Thanks

VB
```Dim BigInt As BigInteger = "22758377872047801994499502579404088515069830671470709664446026543569013625861699705718264701424487993283566718344462216931566145674100201708773768933908779361002052920749"
Dim Base = 15
Dim Exp As Double = BigInteger.Log(BigInt, Base) 'logarithm: This is integer 144 (returned from .NET but i think this is wrong)
Dim Pwr = BigInteger.Pow(Base, Exp) 'Power: This must be equal to BigInt if logarithm is 144
Dim Div As BigInteger = BigInteger.Divide(BigInt, Pwr) 'Divide: Result is 0 but this must be 1 if logarithm is 144
Dim Subs = BigInteger.Subtract(BigInt, Pwr) 'Subtraction: This must be always positive but this is negative
```

What I have tried:

```         BigInt = new BigInteger("22758377872047801994499502579404088515069830671470709664446026543569013625861699705718264701424487993283566718344462216931566145674100201708773768933908779361002052920749");

object Base = 15;
double Exp = BigInteger.Log(BigInt, Base);
object Pwr = BigInteger.Pow(Base, Exp);
BigInteger Div = BigInteger.Divide(BigInt, Pwr);
object Subs = BigInteger.Subtract(BigInt, Pwr);```
Posted
Updated 20-Apr-22 21:56pm
v5

Solution 1

This is not a code conversion service: we are not here to translate code for you.
Even if we did, what you would end up with would not be "good code" in the target language – they are based on very different frameworks, and what makes something work in one language does not always "translate" directly into another.
So what you end up with is very poor code, that is difficult if not impossible to maintain, that can’t be upgraded nicely, and that will cause you immense headaches if the original is changed. And it'll be a nightmare to debug if it doesn’t work "straight out of the box".
Instead, use the source code as a specification for a new app written in and for the target language / framework and write it from scratch using the original as a "template". You will get a much, much better result that will save you a lot of time in the long run.

Solution 2

Quote:
Can you convert and run this VB.NET code in java editor?

Yes, I can, but I will not.
Quote:
I am getting error with the code below on .Net.

Try to tell us the error message and position, or problem, you will be more likely to get help.

Nota : your code look specially crafted to get rounding errors.