C言語 小数点の切り捨て - math.h - [ floor ]
2008.09.03 Wednesday | by LRESULT
浮動小数点の、『6.54321』 と 『-6.54321』 を切り捨てした値を求めます。 |
---|
#include <stdio.h> #include <math.h> int main(void) { double a = floor( 6.54321 ); double b = floor( -6.54321 ); printf( "a=%f b=%f¥n", a, b ); return 0; } |
a=6.000000 b=-7.000000 |
---|
切り捨ててますね。 |