0

I am C# developer and I have UWP app which can precisely calculate many math related problems using DecimalEx Nuget package. I recently started porting my app to Java and Android, and I use Apfloat as alternative (if there is better one please recommend me). I wrote a code to calculate trigonometry functions, but the result is 10 times greater than the actual. Here is the sample of my code:

            Apfloat degrees = new Apfloat(new BigDecimal(textbox1.getText().toString()), 20);
            Apfloat sin  = ApfloatMath.sin(degrees);
            Apfloat cos = ApfloatMath.cos(degrees);
            Apfloat tg = ApfloatMath.tan(degrees);
            Apfloat cotg = new Apfloat(1).divide(tg);
            Apfloat sec = new Apfloat(1).divide(cos);
            Apfloat csc = new Apfloat(1).divide(sin);

The precision is set to 20. Here's a screenshot comparing my C# output (which is accurate, on right) vs the Java output.

enter image description here

Also I am unaware how to display the result without scientific notation.

Thank you in advance. :)

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Krum Cvetkov
  • 63
  • 1
  • 10

1 Answers1

0

Turns out it was just formatting issue, found solution.

String.format("%#s", sin)

And so on ;)

Krum Cvetkov
  • 63
  • 1
  • 10