- #1

- 6

- 0

## Main Question or Discussion Point

Hi! I want to calculate the smallest floating point x such that x+2=x. I've written a programme in C that does not actually determines the smallest floating point x such that x+2=x, but rather determines a power of two within an interval that contains the smallest floating point x. Does anyone have any ideas how can I improve this solution or find out a new one? Is there any built-in function in MATLAB and/or C to get accurate approximations of that x?

Code:

```
#include <stdio.h>
int main( int argc, char **argv )
{
float x = 1.0f;
printf( "current x \t 2 + current x\n" );
do {
printf( "%G\t\t %.20f\n", x, (2.0f + x) );
x *= 2.0f;
}
while ((float)(2.0 + x) != x);
printf( "\nCalculated x: %G\n", x );
return 0;
}
```

Code:

`Calculated x: 3.68935E+019`