Floating-Point Hazard (数学)

Posted 0xiaoyu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Floating-Point Hazard (数学)相关的知识,希望对你有一定的参考价值。

https://vj.z180.cn/c7965da2b8fbd28dfbce93c000a232e5?v=1578704227

技术图片

题意:

高精度求和

思路:

用求导定义得出所求式子可化为对i^(1/3)求导的和*1e5,即求1/3*i^(-2/3)的和*1e15

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <math.h>
 4 
 5 int main()
 6 {
 7     int i, low, high, num;
 8     double sum;
 9     while(~scanf("%d %d", &low, &high)&&low&&high)
10     {
11         sum = 0.0;
12         for(i=low; i<=high; i++)
13         {
14             sum = sum + pow(i, -2.0 / 3.0) / 3.0;
15         }
16         num = 15;
17         while(sum < 1)
18         {
19             sum *= 10;
20             num++;
21         }
22         while(sum > 10)
23         {
24             sum /= 10;
25             sum--;
26         }
27         printf("%.5lfE-%03d
", sum, num);
28     }
29     return 0;
30 }

以上是关于Floating-Point Hazard (数学)的主要内容,如果未能解决你的问题,请参考以下文章

CPU五级流水线project(带Hazard)

UVa 11809 - Floating-Point Numbers

UVA 11809 Floating-Point Numbers

13 Hazard of Overfitting

UVA 12165 Triangle Hazard

when|nobody|hazard|lane|circuit|