Click here to Skip to main content
15,072,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
#include <stdio.h>
int main(void)
    long double x,eps=1.0,a; 
    while( x+eps>x);
    printf("Grid step: %Le",(long double)a);
    return 0;

What I have tried:

I wrote such a code to find the grid step(difference between two adjacent machine-representable numbers, machine epsilon the difference between the minimum machine-representable number greater than one and one), the teacher says: Give examples for which the program gives the wrong answer. How do you fix the program to make it work correctly? Help please
Updated 11-Apr-21 6:10am
Rick York 11-Apr-21 12:27pm
Microsoft's C compiler does not have a long double type. It is folded into the plain, old, eight-byte data type. I don't know about any other compilers.
Richard MacCutchan 12-Apr-21 4:22am
What is the correct answer?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900