How to return the decimal part of ofGetElapsedTimef()?

Is there a way to return only the decimal part of the float that ofGetElapsedTimef() returns?

That’s typically known as the “fractional” part of a float (googling it and c++ will get a few techniques). Here’s one, using std::modf (which will also give you the integral part) :

float now = ofGetElapsedTimef();
float integral;
float fractional = modf(now, &integral);
cout << "fractional: " << fractional << " integral: " << integral << endl;
1 Like