我怎样才能得到的数字在许多总数的计数? [英] How can I get a count of the total number of digits in a number?

查看:78
本文介绍了我怎样才能得到的数字在许多总数的计数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能获得在C#中位数总数的计数?例如,该号码887979789具有9位。

How can I get a count of the total number of digits of a number in C#? For example, the number 887979789 has 9 digits.

推荐答案

无须转换为字符串,你可以尝试:

Without converting to a string you could try:

Math.Ceiling(Math.Log10(n));

校正以下ysap的评论:

Math.Floor(Math.Log10(n) + 1);

这篇关于我怎样才能得到的数字在许多总数的计数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆