余弦函数返回长双(高分辨率) [英] cosine function returning long double (high resolution)

查看:51
本文介绍了余弦函数返回长双(高分辨率)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前在math.h中使用余弦函数


目前我得到:


1 = cos(1e ^ -7)


还有另一种方法可以让cos返回高精度的值说:


0.999999 = cos(1e ^ -7)

Currently using cosine function in math.h

Currently I get:

1 = cos(1e^-7)

Is there another way for cos to return value of high accuracy say:

0.999999 = cos(1e^-7)

推荐答案

ra ******* @ gmail.com 写道:

目前在math.h中使用余弦函数


目前我得到:


1 = cos(1e ^ -7)


还有另一种方法可以让cos返回高精度的值说:


0.999999 = cos(1e ^ -7)
Currently using cosine function in math.h

Currently I get:

1 = cos(1e^-7)

Is there another way for cos to return value of high accuracy say:

0.999999 = cos(1e^-7)



如果你使用lcc-win编译器你会得到

cos(1e-7)=

0.999999999999995000000000000004166666666666665277 77777777777802579365079365076609347442680776222876 9173214

使用额外精度浮点(qfloat)。

In标准C最大的浮点类型很长双倍。


无法用标准C做到这一点。


-

jacob navia
jacob at jacob point remcomp point fr

logiciels / informatique
http://www.cs.virginia.edu/~lcc-win32

If you use the lcc-win compiler you get

cos(1e-7)=
0.999999999999995000000000000004166666666666665277 77777777777802579365079365076609347442680776222876 9173214
using the extra precision floating point (qfloat).
In standard C the biggest floating point type is long double.

No way to do that in standard C.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32


jacob navia写道:
jacob navia wrote:
ra*******@gmail.com 写道:
ra*******@gmail.com wrote:

>目前在math.h中使用余弦函数

目前我得到:

1 = cos( 1e ^ -7)

还有另一种方法可以让cos返回高精度的值说:

0.999999 = cos(1e ^ -7)
>Currently using cosine function in math.h

Currently I get:

1 = cos(1e^-7)

Is there another way for cos to return value of high accuracy say:

0.999999 = cos(1e^-7)



如果你使用lcc-win编译器你会得到


cos(1e-7)=

0.999999999999995000000000000004166666666666665277 77777777777802579365079365076609347442680776222876 9173214


使用额外的精度浮点(qfloat)。


在标准C中,最大的浮点类型是long double。


无法在标准C中执行此操作。


If you use the lcc-win compiler you get

cos(1e-7)=
0.999999999999995000000000000004166666666666665277 77777777777802579365079365076609347442680776222876 9173214

using the extra precision floating point (qfloat).
In standard C the biggest floating point type is long double.

No way to do that in standard C.



PS


等待


这是.00000000000000499999999999999,一个数字这大于

DBL_EPSILON。


可能你的问题是打印问题?


你做了哪种格式?用来打印吗?


-

jacob navia

jacob at jacob point remcomp point fr

logiciels / informatique
http://www.cs。 virginia.edu/~lcc-win32


ra * ******@gmail.com 写道:

目前在math.h中使用余弦函数


目前我得到:


1 = cos(1e ^ -7)


还有另一种方式来cos返回高精度值说:


0.999999 = cos(1e ^ -7)
Currently using cosine function in math.h

Currently I get:

1 = cos(1e^-7)

Is there another way for cos to return value of high accuracy say:

0.999999 = cos(1e^-7)



此程序:

#include< math.h>

#include< stdio.h>

int main(无效)

{

printf("%40.17Lf \ n",cosl(1e-7));

}


打印

0.99999999999999500

-

jacob navia

jacob at jacob point remcomp point fr

logiciels / informatique
http:// www。 cs.virginia.edu/~lcc-win32


这篇关于余弦函数返回长双(高分辨率)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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