我想计算transmitter.getETXPOW()
的对数,BigDecimal
格式。
BigDecimal power = transmitter.getETXPOW();
BigDecimal eirp = 10 * Math.log(power);
我收到一条错误消息,BigDecimal
无法转换为double
。
对数基数为10.
答案 0 :(得分:1)
要转换为双值,请使用BigDecimal
类doubleValue()
。见演示
import java.math.*;
public class BigDecimalDemo {
public static void main(String[] args) {
// create a BigDecimal object
BigDecimal bg;
// create a Double object
Double d;
bg=new BigDecimal("1234");
// assign the converted value of bg to d
d=bg.doubleValue();
String str = "Double value of " + bg + " is " + d;
// print d value
System.out.println( str );
}
}