Skip to content

Instantly share code, notes, and snippets.

@AliZafar120
Created August 15, 2014 00:01
Show Gist options
  • Save AliZafar120/cfdc1b2bef5607913e28 to your computer and use it in GitHub Desktop.
Save AliZafar120/cfdc1b2bef5607913e28 to your computer and use it in GitHub Desktop.
BasicCalculator class
package edu.univdhaka.iit.calculator;
import java.math.BigInteger;
public class BasicCalculator {
public BigInteger add(BigInteger a,BigInteger b)
{
return a.add(b);
}
public BigInteger subtract(BigInteger a,BigInteger b)
{
if (b.compareTo(a)==-1) return a.subtract(b);
else if (a.compareTo(b)==-1) return b.subtract(a);
else return a.subtract(b) ;
}
public BigInteger multiply(BigInteger a,BigInteger b)
{
return a.multiply(b);
}
public BigInteger divide(BigInteger a,BigInteger b)
{
//BigInteger result = new BigInteger(a.doubleValue());
return a.divide(b);
}
public BigInteger exponent(BigInteger a,int b)
{
return a.pow(b);
}
public double squareroot(double a)
{
return Math.sqrt(a);
}
public int percentage(int a,int b)
{
return a*b/100;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment