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; }