我正在尝试检查浮点变量的数字长度,但我不知道要使用的正确语法。我已经查过了,但找不到答案。
我的代码是一个简单的 if 语句:
if (currentNumber.digits < 3) { //If the number has less that three digits, I don't know what to put here to get it working
//code
}
最佳答案
#include <math.h>
//...
int digits = (int) ceil(log10(number));
负数的额外逻辑留给读者作为练习。
关于objective-c - 检查 float 的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11366601/