Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的项目中使用 NCalc 来评估表达式。该框架包括一组已实现的功能,可在此处找到。
我对计算数字或字符串的长度感兴趣。我可以仅使用内置函数来实现吗?
要获取整数的长度,您可以执行以下操作 -
int length = ceiling(log10(number));
但是这样的方法会非常有效-
int countLength(int number){ if(number>9) return countLength(number/10) + 1; return 1; }