Floating-Point - IEEE 754


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main (void) {
    time_t t;
    int n;
    float f1 = 1;
    float f2;
    float f3 = 100;
    float f4 = 0;
    float f5 = 0.001;


    srand ((unsigned )time (&t));

    f2 = (float) (rand () % (8192 * 4));

    n = (rand () % 8) + 2;

    while (n > 0) {
        f1 = f1 / 2;
        f3 = f3 / 10;
        f4 = f4 + (f3 * (rand () % 10));
        f5 = f5 / 2;
        n--;
    }

    f2 = f2 + f1 + f4 + f5;

    printf ("Rechne die Zahl in IEEE-754 um %f\n", f2);


return 0;
}

Image IMG_5211

Image IMG_5212

Image IMG_5213

Image IMG_5214

Image IMG_5215

Image IMG_5217

Image IMG_5218


Rechne die Zahl in IEEE-754 um 14057.250000
Rechne die Zahl in IEEE-754 um 9819.825195
Rechne die Zahl in IEEE-754 um 29525.343750