tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] uint64_t/int64_t => double broken on ARM


From: Christian Jullien
Subject: [Tinycc-devel] uint64_t/int64_t => double broken on ARM
Date: Tue, 28 Jan 2014 06:51:53 +0100

Hi all,

 

Playing with clock_gettime and uint64_t/int64_t on RPi (ARM), I discovered uint64_t => double conversion bug :

NOTE: tcc is compiled using --with-libgcc

 

#include <stdint.h>

#include <stdio.h>

 

static uint64_t x1 = 123456789;

static uint32_t x2 = 123456789;

int

main()

{

        double d1 = (double)x1;

        double d2 = (double)x2;

        printf("d = %g\n", d1);

        printf("%d => %g\n", (uint32_t)x1, d1); // x1 is not 0

        printf("%d => %g\n", (uint32_t)x2, d2); // works if x2 is uint32_t

}

 

$ tcc foo.c && ./a.out

d = 0

123456789 => 0

123456789 => 1.23457e+08

 

Changing uint64_t to int64_t produces the same bug.

 

Christian


reply via email to

[Prev in Thread] Current Thread [Next in Thread]