floating point - How to get the opposite side of round()/floor() in C? -
i have double a=1234.5678
, can 1234
floor(a)
, how 0.5678
? know can subtract a-floor(a)
, there function in runtime library?
modf
break double value in 2 parts
double param, fractpart, intpart; param = 3.14159265; fractpart = modf (param , &intpart); printf ("%f = %f + %f \n", param, intpart, fractpart); return 0;
output: 3.141593 = 3.000000 + 0.141593
you have include math.h
Comments
Post a Comment