小编use*_*794的帖子

为什么我的程序只打印到小数点后6位?

我已经创建了一个程序来计算从零到无穷大的积分值,但是当我打印我的答案时,它只打印到6位小数,有人可以告诉你这是为什么吗?

首先十分感谢 :)

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

double integral_Function(double x){
    double value;
    value = 1/((1+ pow(x, 2))*(pow(x, 2/3)));
    return value;
}

double trapezium_Rule(double lower, double upper, int n){

    double h;
    double total;

    h = (upper - lower)/n;

    total = (h/2) * (integral_Function(upper) + integral_Function(lower));

    for(int i = 1; i < n; i++){
        total = total + (h * integral_Function(lower + (i * h)));
    }

    return total;

}

int main() {

    double sum = 0;
    double upper = DBL_MIN …
Run Code Online (Sandbox Code Playgroud)

c double printf decimal-point

1
推荐指数
1
解决办法
788
查看次数

标签 统计

c ×1

decimal-point ×1

double ×1

printf ×1