Skip to content

Latest commit

 

History

History
52 lines (29 loc) · 1.13 KB

File metadata and controls

52 lines (29 loc) · 1.13 KB

 

 

 

 

 

 

std::modf splits a double into its integer and a fractional part, for example it splits 12.34 into 12 and 0.34.

 

 


#include <cmath> #include <iostream> int main() {   double int_part = 0.0;   const double fraction_part = std::modf(M_E,&int_part);   std::cout << M_E << " = "     << int_part << " + " << fraction_part << '\n'; }

 

Screen output:

 


2.71828 = 2 + 0.718282