conv_int_float_s.c (698B)
1 /* Signed int <-> float round-trip: SCVTF (int->float) and FCVTZS 2 * (float->int, truncating toward zero). volatile operands defeat folding so 3 * the conversions are really emitted. 4 * 5 * i = 42 : f = (float)i = 42.0f (scvtf s, w) 6 * back : (int)f = 42 (fcvtzs w, s) 7 * neg : (float)(-5) = -5.0f ; (int)(-5.0f*1.0f) = -5 exercises sign. */ 8 int test_main(void) { 9 volatile int i = 84; 10 volatile int j = -5; 11 float f = (float)i; /* 84.0f, scvtf s,w */ 12 float g = (float)j; /* -5.0f, scvtf s,w */ 13 int bi = (int)(f / 2.0f); /* 42, fcvtzs w,s */ 14 int bj = (int)g; /* -5, fcvtzs w,s */ 15 return bi + bj + 5; /* 42 - 5 + 5 = 42 */ 16 }