tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] An issue with literal floats


From: Hernán J . González
Subject: [Tinycc-devel] An issue with literal floats
Date: Wed, 25 Feb 2015 20:15:41 -0300

I don't understand how this happens. 

Notice that this is not an issue about floating point rounding, both
assignments (t2a t2b) should be exactly equivalent, but they are not.

/************************************************/
#include<stdio.h>
int main() {
    int t1 = 176401255;
    float f = 0.25f;
    int t2a = (int)(t1 * f);
    int t2b = (int)(t1 * (float)0.25f);
    printf("t2a=%d t2b=%d \n",t2a,t2b);
    return 0;
}
/************************************************/

prints 

t2a=44100313 t2b=44100312

Using tcc version 0.9.26 (i386 Win32)


--
Hernán J. González




--
Hernán J. González


reply via email to

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