我是初学者,有一个问题,我有以下代码,想要在两个文本字段中输入 2 个值,公式来 self 的 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/math.floor/math.log
最佳答案
通过以下方式更改您的代码:
double co2Ergebnis=floor((7.90+log(khWert/(2.8*phWert))/log(10))*100.0)/100.0;
不要忘记在头文件中包含 math.h。
关于java - 将 Java 表达式/公式转换为 Objective-C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23308410/