#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
unsigned int uint10log10(unsigned int value);
void main(int argc,char* argv[])
{
if(argc<2)
{
printf("Please usage:10log10.exe value\n");
return;
}else{
int i = 0;
while(argv[1][i])
{
if(isdigit(argv[1][i]))
{
++i;
continue;
}
else
{
printf("the type of intput value is not unsigned int\n");
return;
}
}
unsigned int value = atoi(argv[1]);
unsigned int ret10log10 = uint10log10(value);
printf("\n10log(%u)=%u\n",value,ret10log10);
}
}
/*get a rough value because the type is not float
*but the biggest margin of error is 3
*/
unsigned int uint10log10(unsigned int value)
{
unsigned int retlog = 0;
while(value > 10 || value == 10 )
{
++retlog;
value /= 10;
}
retlog *= 10;
//value = pow(value,10); pow require the type of valu
对于不支持浮点型的10log10运算实现
最新推荐文章于 2024-06-05 11:46:22 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)