[informatik-bonn] eps

  • From: Lutz Oberst <oberst@xxxxxxxxxxx>
  • To: informatik-bonn@xxxxxxxxxxxxx
  • Date: Wed, 5 Nov 2003 15:14:50 +0100

Moin,

Aufgabe 9: euer eps ist zu gross

road@runner:/tmp$ ./a.out 
machine Epsilon: 2.22045e-16
road@runner:~/studium/prama/zettel3$ ./a.out 
1.0842e-19

code haengt an.

Bye, Lutz
-- 
signature intentionally left blank
#include <stdlib.h>
#include <math.h>
#include <stdio.h>

/* 
        compilieren mit gcc -Wall -std=c99 wegen NAN und HUGE_VAL
*/

int main(void)
{
        double eps=1, eps_old;
                
        do
        {
                eps_old = eps;
                eps = eps / 2;
           
                /* extemwerte abfangen */
                if (eps == NAN || eps == HUGE_VAL || eps == -HUGE_VAL)
                        exit(EXIT_FAILURE);

        } while (1+eps != 1);

        printf("%g\n", eps);
                
        exit(EXIT_SUCCESS);
}

Other related posts:

  • » [informatik-bonn] eps