How to extract the decimal part from a floating point number in C++

1 Answer

0 votes
#include <iostream>

int main(void)
{
    double d = 95.837206;
    double integral;
   
    int intpart = (int)d;
    double decimalpart = d - intpart;
 
    std::cout << decimalpart;
}
     
      
      
      
/*
run:
   
0.837206

*/

 



answered Nov 16, 2023 by avibootz
...