Created
September 24, 2016 22:01
-
-
Save jtara1/7d2aa09ef6fc9a7db824bf59ef1dffad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClass { | |
public static void main(String[] args) { | |
BigDecimal[] mathArray2 = mathStuff2(); | |
System.out.println("mathStuff2 func return:"); | |
for (BigDecimal num: mathArray2) { | |
System.out.println(num); | |
} | |
public static BigDecimal[] mathStuff2() { | |
double area, theta, x, y; | |
double r = 1.0; // radius of unit circle | |
area = Math.PI * Math.pow(r, 2.0); | |
theta = (1.0 / 2) * Math.PI; // 1/2 PI radians | |
x = r * Math.cos(theta); | |
y = r * Math.sin(theta); | |
// convert double variables to BigDecimal inside of new BigDecimal array | |
BigDecimal[] ret = new BigDecimal[]{ | |
new BigDecimal(area), | |
new BigDecimal(theta), | |
new BigDecimal(x), | |
new BigDecimal(y) | |
}; | |
for (BigDecimal val: ret) { | |
val.setScale(7, RoundingMode.FLOOR); | |
} | |
return ret; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment