printing the integral part of a floating point number

后端 未结 7 481
不知归路
不知归路 2021-01-13 23:03

I am trying to figure out how to print floating point numbers without using library functions. Printing the decimal part of a floating point number turned out to be quite ea

相关标签:
7条回答
  • 2021-01-13 23:54

    I believe the problem lies in value /= base; Do not forget that 10 is not a finite fraction in binary system and thus this calculation is never correct. I also assume some error will occur in fmod due to the same reason.

    printf will first compute the integral part and then convert it to decimal(if I get the way you printf the integral part correctly).

    0 讨论(0)
提交回复
热议问题