我是初学者并且有一个问题,我有以下代码,想要在两个文本字段中输入的2个值,该公式来自我的Java代码,但在Objective-C中不起作用,
如何更改以下内容以使其在Objective-C中运行?
double phWert = [self.phWert.text doubleValue];
double khWert = [self.khWert.text doubleValue];
double co2Ergebnis=Math.floor((7.90+Math.log(khWert/(2.8*phWert))/Math.log(10))*100)/100;
self.co2Wert.text = [NSString stringWithFormat:@"%f", co2Ergebnis];
这里的问题显然是数学/math.floor/math.log
答案 0 :(得分:1)
通过以下方式更改您的代码:
double co2Ergebnis=floor((7.90+log(khWert/(2.8*phWert))/log(10))*100.0)/100.0;
不要忘记在头文件中包含math.h。