Getting the fractional part of a double value in integer without losing precision
问题 i want to convert the fractional part of a double value with precision upto 4 digits into integer. but when i do it, i lose precision. Is there any way so that i can get the precise value? #include<stdio.h> int main() { double number; double fractional_part; int output; number = 1.1234; fractional_part = number-(int)number; fractional_part = fractional_part*10000.0; printf("%lf\n",fractional_part); output = (int)fractional_part; printf("%d\n",output); return 0; } i am expecting output to be