java - 将 Java 表达式/公式转换为 Objective-C

标签 java ios objective-c

我是初学者,有一个问题,我有以下代码,想要在两个文本字段中输入 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/

相关文章:

ios - Swift 3 - 将 bool 值发送到不同的类

ios - PresentViewController 来自 AppDelegate handleActionWithIdentifier

ios - 在不首先获取对象的情况下更新 Parse 上的值(如 SQL 更新)

c++ - 将 C++ 从 Oreilly 书籍转换为 Objective-C 的问题(iOS 3D 编程)

java - 构建良好的 Android Studio 项目上的 NoClassDefFoundError

java - 通过 android studio 使用子字符串时出现错误

java - Windows 和 Mercurial 更改类名的大小写

ios - Swift:解析 JSON 请求中的数组元素

java - FileChooserBuilder 未显示在屏幕中央

ios - MMdrawercontroller:打开左侧菜单时点击centerVC