As I noted in a comment:
On machines such as x86/64 architecture, floating point values are passed in one set of registers; integers in a different set of registers. Once the floating point register is set to 2.5, the integer arithmetic doesn't change it. The behaviour is undefined, but that's an explanation of what happens. Try:
printf("%f %d\n", 355.0/113.0, 355/113);
printf("%f %d\n", 355/113, 355.0/113.0);
Given what you're seeing, I expect you to see the same output twice. My Mac gives the same answer twice, even though the arguments are reordered.
Source:
#include <stdio.h>
int main(void)
{
printf("%f %d\n", 355.0/113.0, 355/113);
printf("%f %d\n", 355/113, 355.0/113.0);
return 0;
}
Output:
3.141593 3
3.141593 3
I note that I have to avoid my default compilation options — otherwise, it doesn't compile.
Default compilation:
$ gcc -O3 -g -std=c11 -Wall -Wextra -Werror -Wmissing-prototypes -Wstrict-prototypes -fno-common -c fl43.c
fl43.c: In function ‘main’:
fl43.c:6:14: error: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Werror=format=]
6 | printf("%f %d\n", 355/113, 355.0/113.0);
| ~^ ~~~~~~~
| | |
| double int
| %d
fl43.c:6:17: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘double’ [-Werror=format=]
6 | printf("%f %d\n", 355/113, 355.0/113.0);
| ~^ ~~~~~~~~~~~
| | |
| int double
| %f
cc1: all warnings being treated as errors
$