[英]issue with converting excel formula to java
Hi i am new to java can anyone help me to convert this formula to java code? 嗨,我是Java新手,有人可以帮助我将此公式转换为Java代码吗?
=ROUNDUP(POWER(4*B18/PI(),1/3)*100,0)
So far, I have this code: 到目前为止,我有以下代码:
(((4*variable)/3.142)*0.34)*100;
sorry for asking basic question 很抱歉提出基本问题
In its raw (and ugly) form, it should be something like this: 原始(丑陋)的形式应该是这样的:
static double yourFormula(double b18) {
return Math.ceil(Math.pow(4.0 * b18 / Math.PI, 1.0/3) * 100.0);
}
EDIT: As noted by @Teepeemm, Math#cbrt
already calculates the cube root of a number. 编辑:如@Teepeemm所述,
Math#cbrt
已经计算出一个数字的立方根。 So the formula should be 所以公式应该是
static double yourFormula(double b18) {
return Math.ceil(Math.cbrt(4.0 * b18 / Math.PI) * 100.0);
}
double multiplies =8 * 4;
System.out.println(Math.floor(Math.pow( multiplies/ Math.PI, 1.0/3)*100.0));
double multiplies =8 * 4;
System.out.println(Math.ceil(Math.pow( multiplies/ Math.PI, 1.0/3)*100.0));
double multiplies =8 * 4;
System.out.println(Math.round(Math.pow( multiplies/ Math.PI, 1.0/3)*100.0));
depending on your usage you can use this three methods 根据您的用法,您可以使用以下三种方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.