How do I cut off decimal places in C without rounding?
For example if the number is 4.48
4.48
it will just show 4.4
4.4
%.1f rounds to 4.5
%.1f
4.5
You can (ab)use the fact that integer division truncates and doesn't round:
float original = 4.48; int tmp = original * 10; // 44.8 truncated to 44 float truncated = tmp / 10.0; // 4.4
1.4m articles
1.4m replys
5 comments
57.0k users