如何使用长双浮? [英] How to use long double floating?

查看:96
本文介绍了如何使用长双浮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

指南说在printf()函数中使用%f,使用关键字

float和double。


例如


浮动a = 1.2345;

双b = 5.166666667;


printf("%。2f \ n%f \ n",a,b);


现在,我想使用long double而不是double来获得准确度

十进制数,它比正常值大数字如亿元

数字。我认为它将是%dd,但它不正确。你可以吗?
请提供它支持的长双倍的信息吗?

谢谢...


布莱恩·帕克夫

解决方案

Bryan Parkoff写道:

该指南说使用关键字
在printf()函数中使用%f漂浮和双倍。


在printf函数族中使用%f来输出''float''类型的值

或''double''。同样的说明符适用于两者的原因是任何

类型''float''的值都被提升为''double''。

例如

浮动a = 1.2345;
双b = 5.166666667;

printf("%。2f \ n%f \ n",a,b);

现在,我想使用long double而不是double来获得精确度十进制数,它比正常数字(如十亿数字)大。我认为它将是%dd,但它不正确。可以吗>请你提供它支持的信息长一倍,
好吗?谢谢...



标准规定你应该使用''L''宽度前缀(比如


%.2Lf

)输出''long double''值。


V




" Victor Bazarov" <五******** @ comAcast.net>在消息中写道

新闻:Qr ******************** @ comcast.com ...

布莱恩Parkoff写道:

指南说使用关键字
float和double在printf()函数中使用%f。



使用%f in printf函数族输出类型''float''
或''double''的值。同样的说明符适用于两者的原因是任何类型''float''的值都被提升为''double''。


例子

浮动a = 1.2345;
双b = 5.166666667;

printf("%。2f \ n%f \ n",a, b);

现在,我想使用long double而不是double来获得准确度十进制数,它比正常数字(如十亿数字)大。我认为它将是%dd,但它不正确。可以吗>请你提供它支持的信息长一倍,
好吗?谢谢......



标准规定你应该使用''L''宽度前缀(比如

%。2Lf
)输出''long double''值。

V



Victor,


谢谢为我提供答案,但这个十进制有6位数字

在。之后。它需要是10位到20位数才能获得最佳精确度十进制值

数字。 %Lf怎么可能有帮助? %Lf仍然提供6位数。

如何克服限制?


Bryan Parkoff




" Bryan Parkoff" <无** @ nospam.net>在消息中写道

新闻:Xh ******************* @ newssvr21.news.prodigy。 com ...


" Victor Bazarov" <五******** @ comAcast.net>在消息中写道
新闻:Qr ******************** @ comcast.com ...

Bryan Parkoff写道:< blockquote class =post_quotes>指南说使用关键字
float和double在printf()函数中使用%f。



在printf函数族中使用%f输出类型''float''
或''double''的值。同样的说明符适用于两者的原因是任何类型''float''的值都被提升为''double''。


例子

浮动a = 1.2345;
双b = 5.166666667;

printf("%。2f \ n%f \ n",a, b);

现在,我想使用long double而不是double来获得准确度十进制数,它比正常数字(如十亿数字)大。我认为它将是%dd,但它不正确。可以吗>请你提供它支持的信息长一倍,
好吗?谢谢......



标准规定你应该使用''L''宽度前缀(比如

%。2Lf
)输出''long double''值。

V


Victor,

感谢您给我答案,但是这个十进制有6位数字
在。之后。它需要是10位到20位才能获得最佳精度
十进制数。 %Lf怎么可能有帮助? %Lf仍提供6位数字。我如何克服限制?




printf("%。20Lf \ n",b);


你的教科书在哪里?


-Mike


The guideline says to use %f in printf() function using the keyword
float and double.

For example

float a = 1.2345;
double b = 5.166666667;

printf("%.2f\n %f\n", a, b);

Now, I want to use long double rather than double to get accuracy
decimal number which it is larger than normal number such as billion
numbers. I assume that it would be %dd, but it is not correct. Can you
please provide the information which it support long double, please?
Thanks...

Bryan Parkoff

解决方案

Bryan Parkoff wrote:

The guideline says to use %f in printf() function using the keyword
float and double.
Use %f in printf family of functions to output a value of type ''float''
or ''double''. The reason the same specifier works for both is that any
value of type ''float'' is promoted to ''double'' anyway.

For example

float a = 1.2345;
double b = 5.166666667;

printf("%.2f\n %f\n", a, b);

Now, I want to use long double rather than double to get accuracy
decimal number which it is larger than normal number such as billion
numbers. I assume that it would be %dd, but it is not correct. Can
you please provide the information which it support long double,
please? Thanks...


The Standard specifies that you should use ''L'' width prefix (like

%.2Lf

) to output a ''long double'' value.

V



"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Qr********************@comcast.com...

Bryan Parkoff wrote:

The guideline says to use %f in printf() function using the keyword
float and double.



Use %f in printf family of functions to output a value of type ''float''
or ''double''. The reason the same specifier works for both is that any
value of type ''float'' is promoted to ''double'' anyway.


For example

float a = 1.2345;
double b = 5.166666667;

printf("%.2f\n %f\n", a, b);

Now, I want to use long double rather than double to get accuracy
decimal number which it is larger than normal number such as billion
numbers. I assume that it would be %dd, but it is not correct. Can
you please provide the information which it support long double,
please? Thanks...


The Standard specifies that you should use ''L'' width prefix (like

%.2Lf

) to output a ''long double'' value.

V


Victor,

Thank you for providing me the answer, but this decimal has 6 digits
after ".". It needs to be 10 digits to 20 digits for best accuracy decimal
numbers. How is it possible that %Lf help? %Lf still provides 6 digits.
How do I overcome the limit?

Bryan Parkoff



"Bryan Parkoff" <no**@nospam.net> wrote in message
news:Xh*******************@newssvr21.news.prodigy. com...


"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Qr********************@comcast.com...

Bryan Parkoff wrote:

The guideline says to use %f in printf() function using the keyword
float and double.



Use %f in printf family of functions to output a value of type ''float''
or ''double''. The reason the same specifier works for both is that any
value of type ''float'' is promoted to ''double'' anyway.


For example

float a = 1.2345;
double b = 5.166666667;

printf("%.2f\n %f\n", a, b);

Now, I want to use long double rather than double to get accuracy
decimal number which it is larger than normal number such as billion
numbers. I assume that it would be %dd, but it is not correct. Can
you please provide the information which it support long double,
please? Thanks...


The Standard specifies that you should use ''L'' width prefix (like

%.2Lf

) to output a ''long double'' value.

V


Victor,

Thank you for providing me the answer, but this decimal has 6 digits
after ".". It needs to be 10 digits to 20 digits for best accuracy
decimal numbers. How is it possible that %Lf help? %Lf still provides 6
digits. How do I overcome the limit?



printf("%.20Lf\n", b);

Where''s your textbook?

-Mike


这篇关于如何使用长双浮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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