How to separate float into an integer and a fractional part?

后端 未结 3 982
天涯浪人
天涯浪人 2021-01-04 18:17

I am willing to cast precise operations and for that purpose I need a way to seperate a float number into an integer and a fractional part. Is there any way for this?

3条回答
  •  滥情空心
    2021-01-04 19:03

    A thought crossed my mind to separate them with some logic :

        #include 
    
    using namespace std;
    int main()
        {
        double fr,i,in,num=12.7;
        for(i=0;i

    Hope this was what you were searching for:) .

提交回复
热议问题