数学q [英] math q

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

问题描述

这是我最近的代码:


#include< stdio.h>

#include< math.h>


int main(){

if((printf("%d",pow(2,128))== 0)

{fprintf(stderr," 0 error");

返回-1;

}

返回0;

}


我意识到还有一个C99 exp2()函数可以做同样的事情。我最初有这个。


#include< stdio.h>

#include< math.h>


int main() {

printf("%d",pow(2,128));

返回0;

}

我试图在第一个代码中添加一个错误例程。这将是

a大数字但是我想要写128位字符串或数字

是唯一的,就像MS的clsids和GUID一样。首先我需要得到一个小数值。

哦是的,有什么方法可以在printf中输出十六进制数来得到十六进制/>
而不是pow()的双重类型。


比尔

我希望这很清楚。

Here''s my code as of latest:

#include <stdio.h>
#include <math.h>

int main() {
if ((printf("%d",pow(2,128))==0)
{ fprintf (stderr,"0 error");
return -1;
}
return 0;
}

I realize there is also a C99 exp2 ( ) function that would do the same
thing. I originally had this.

#include <stdio.h>
#include <math.h>

int main() {
printf("%d",pow(2,128));
return 0;
}

I have tried to add an error routine to the first code. This is going to be
a big number but i''m looking to write 128 bit strings and or numbers that
are unique like MS''s clsids and GUIDs. First I need to get a decimal value.
Oh yes is there any way I can cast a hex number in printf to get a hex
instead of pow ( ) ''s double type.

Bill
I hope this is clear.

推荐答案

Bill Cunningham写道:
Bill Cunningham wrote:

这里是我最近的代码:


#include< stdio.h>

#include< math.h>


int main(){

if((printf("%d",pow(2,128))== 0)

{fprintf(stderr," 0 error");

返回-1;

}

返回0;

}
Here''s my code as of latest:

#include <stdio.h>
#include <math.h>

int main() {
if ((printf("%d",pow(2,128))==0)
{ fprintf (stderr,"0 error");
return -1;
}
return 0;
}



那是不可编译的。修好之后它仍然完全错了。

That''s not compilable. And after fixing it''s still utterly wrong.


我发现还有一个C99 exp2()函数会做同样的事情

的事。我最初有这个。


#include< stdio.h>

#include< math.h>


int main(){

printf("%d",pow(2,128));
I realize there is also a C99 exp2 ( ) function that would do the same
thing. I originally had this.

#include <stdio.h>
#include <math.h>

int main() {
printf("%d",pow(2,128));



Pow返回一个double值。 double的格式说明符是%f。你可能还想使用%Lf说明符来使用long double和powl。


这些函数也可以上溢或下溢。

Pow returns a double value. The format specifier for a double is %f. You
might also want to use long double and powl with the %Lf specifier.

These functions can also overflow or underflow.


返回0;

}


我试图在第一个代码中添加一个错误例程。这将是一个很大的数字,但我想要写128位字符串和/或
数字,这些数字与MS的clsids和GUID一样独特。首先我需要

得到一个小数值。哦,是的,有什么方法可以在printf中输出一个十六进制数字

来获得一个十六进制而不是pow()的双重类型。


Bill

我希望这很清楚。
return 0;
}

I have tried to add an error routine to the first code. This is going
to be a big number but i''m looking to write 128 bit strings and or
numbers that are unique like MS''s clsids and GUIDs. First I need to
get a decimal value. Oh yes is there any way I can cast a hex number
in printf to get a hex instead of pow ( ) ''s double type.

Bill
I hope this is clear.



不,它不是,但是如果你想要非常大的整数值,那么你可能需要使用一个b
$ b扩展精度算术包,如GNU

GMP。


PS。有用于生成UUID的固有例程。为什么不使用?

No it isn''t, but if you want very large integer values, then you''ll
probably have to use an extended precision arithmetic package like GNU
GMP.

PS. There are precanned routines for generating UUIDs. Why not use one?


Bill Cunningham写道:
Bill Cunningham wrote:

>

这是我最近的代码:


#include< stdio.h>

#include< math.h>


int main(){

if((printf("%d",pow(2,128))== 0)

{fprintf(stderr," 0 error");

返回-1;

}

返回0;

}
>
Here''s my code as of latest:

#include <stdio.h>
#include <math.h>

int main() {
if ((printf("%d",pow(2,128))==0)
{ fprintf (stderr,"0 error");
return -1;
}
return 0;
}



您可能需要注意pow()返回一个双倍。


-

Morris Dovey

DeSoto Solar

德索托,爱荷华州美国
http://www.iedu.com/DeSoto/




Morris Dovey< mr ***** @ iedu.com写信息

news:47 *************** @ iedu .com ...

"Morris Dovey" <mr*****@iedu.comwrote in message
news:47***************@iedu.com...

Bill Cunningham写道:
Bill Cunningham wrote:

>>
这是我最近的代码:

#包括< stdio.h>
#include< math.h>

{> {(printf("%d",pow)(2,128) ))== 0)
{fprintf(stderr," 0 error");
返回-1;
}
返回0;
}
>>
Here''s my code as of latest:

#include <stdio.h>
#include <math.h>

int main() {
if ((printf("%d",pow(2,128))==0)
{ fprintf (stderr,"0 error");
return -1;
}
return 0;
}



你可能想要注意pow()返回一个double。


You might want to notice that pow() returns a double.



好​​的疏忽。我认为%d是双倍且%fa浮点数

数。


比尔

OK an oversight. I thought %d was a double and %f a floating point
number.

Bill


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

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