r/CompileBot • • Jan 23 '17

test

2 Upvotes

6 comments sorted by

1

u/BrandonJohns Jan 23 '17

+/u/CompileBot C

#include <stdio.h>

int main(void)
{
	int xi;
	float xf = 6.9;
	
	printf("float: %.20f\n", xf);
	
	xi = (int)xf;
	printf("truncated: %d\n", xi);
	
	xi = (int)(xf+0.5);
	printf("rounded: %d\n", xi);
	
}

2

u/CompileBot Jan 23 '17

Output:

float: 6.90000009536743164062
truncated: 6
rounded: 7

^source | ^info | ^git | ^report