Files
x86-assembly-cheat/compiler-generated/float2int_direct_vs_variable.c
2015-06-04 09:42:42 +02:00

28 lines
438 B
C

/*
http://stackoverflow.com/questions/17220787/c-casting-from-double-to-int
Don't reproduce him.
*/
#include <stdio.h>
#include <stdarg.h>
int main() {
int a;
int d;
double b = 0.41;
/* Cast from variable. */
double c = b * 100.0;
a = (int)(c);
/* Cast expression directly. */
d = (int)(b * 100.0);
printf("c = %f \n", c);
printf("a = %d \n", a);
printf("d = %d \n", d);
return 0;
}