用于返回位数的C函数? [英] C function for returning number of digits?
问题描述
是否有C函数返回输入中的位数
int / long?
示例:
>
numdigits(123)返回3
numdigits(1232132)返回7
Is there a C function that returns the number of digits in an input
int/long?
example:
numdigits(123) returns 3
numdigits(1232132) returns 7
推荐答案
卢克吴 <螺*********** @ gmail.com>写道:
"Luke Wu" <Lo***********@gmail.com> writes:
是否有一个C函数返回输入中的位数
int / long?
示例:
numdigits(123)返回3
numdigits(1232132)返回7
Is there a C function that returns the number of digits in an input
int/long? example: numdigits(123) returns 3
numdigits(1232132) returns 7
了解lagarithms,然后将该知识应用于标准C.
-
Chris。
Learn about lagarithms, then apply that knowledge to standard C.
--
Chris.
Chris McDonald写道:
Chris McDonald wrote:
" Luke Wu" <螺*********** @ gmail.com>写道:
"Luke Wu" <Lo***********@gmail.com> writes:
是否有一个C函数返回输入中的位数
int / long?
Is there a C function that returns the number of digits in an input
int/long?
示例:
numdigits(123)返回3
numdigits(1232132)返回7
numdigits(123) returns 3
numdigits(1232132) returns 7
了解lagarithms,然后将这些知识应用到标准C。
Learn about lagarithms, then apply that knowledge to standard C.
哦我的....不认为这将是一个两个班轮.......谢谢
#include< math.h>
int numdigits(int n)
返回log10(n)+ 1 ;
Ohh my.... didn''t think it would be a two liner.......thank you
#include<math.h>
int numdigits(int n)
return log10(n) + 1;
" Luke Wu" <螺*********** @ gmail.com>写道:
"Luke Wu" <Lo***********@gmail.com> writes:
Chris McDonald写道:
Chris McDonald wrote:
" Luke Wu" <螺*********** @ gmail.com>写道:
"Luke Wu" <Lo***********@gmail.com> writes:
>是否有一个C函数返回输入中的位数
> int / long?
>Is there a C function that returns the number of digits in an input
>int/long?
>例如:
> numdigits(123)返回3
> numdigits(1232132)返回7
>numdigits(123) returns 3
>numdigits(1232132) returns 7
了解lagarithms,然后将这些知识应用到标准C。
Learn about lagarithms, then apply that knowledge to standard C.
哦我的....不认为这将是一个两个班轮..... ..谢谢你
#include< math.h>
int numdigits(int n)
返回log10(n)+ 1;
Ohh my.... didn''t think it would be a two liner.......thank you
#include<math.h>
int numdigits(int n)
return log10(n) + 1;
检查它的原型 - 它是双log10(双x); < br $> b $ b -
克里斯。
Check its prototype - it''s double log10(double x);
--
Chris.
这篇关于用于返回位数的C函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!