Float und Double und Long Double haben die gleiche precision



  • const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384;

    float test1 = PI / (long double)2.0;
    printf("%4.40f \n", test1);

    double test2 = PI / (long double)2.0;
    printf("%4.40lf \n", test2);

    long double test3 = PI / (long double)2.0;
    printf("%4.40Lf \n", test3);

    gibt mi zuruk :

    1.5707963705062866000000000000000000000000
    1.5707963267948966000000000000000000000000
    1.5707963267948966000000000000000000000000

    Optimalization is disabled, und FP precision set to precise



  • Hello,

    that's ok, because there's no way of specifying type float in printf's format specification. Both "%lf" and "%Lf" specify type long double. "%f" specifies type double, not float. And there's no difference between the types double and long double in your programming environment.


Anmelden zum Antworten