fuhsnn / slimcc

C11 compiler with GNU extensions for x86-64 Linux, working towards C23
MIT License
34 stars 4 forks source link

u64 to f32 conversion wrong value above 2^63 #20

Closed fuhsnn closed 11 months ago

fuhsnn commented 11 months ago
#include <stdio.h> 
#include <stdint.h>
int main(void) {
    uint64_t u = 13835058055282163712ULL; // 1.5 * 2^63
    float f = u;
    printf("%f\n", f); 
    // expect: 13835058055282163712.000000
    // got:    -4611686018427387904.000000
}