获取的数位数 [英] Get number of digits of a number

查看:113
本文介绍了获取的数位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些像这样: INT NUM = 36729; 和我想要得到的,组成数(在这种情况下,5位)的位数<。 / p>

我怎样才能做到这一点?


解决方案

使用这个公式:

 如果(NUM)
  返回地面(LOG10(ABS((双)NUM))+ 1);返回1;

I have a number like this: int num = 36729; and I want to get the number of digits that compose the number (in this case 5 digits).

How can I do this?

解决方案

Use this formula:

if(num)
  return floor(log10(abs((double) num)) + 1);

return 1;

这篇关于获取的数位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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