1. ## Another C++ problem

Sorry to keep posting my C++ programing problems but I'm still learning and have questions.
so here is my question I'm trying to take a float variable that is holding the amount of seconds it take for something to happen such as 1928.61582 seconds and break that down into minutes and seconds.

now transTime needs to be a float or i loose the decimal places rite from the beginning which is not good because my time will be off but my code will not work unless every thing is an int which doesn't work either because i need the time for seconds out to the 5th decimal place and if its an int and i force the decimal place i just get all zeros which isnt any good any way. hope you guys understand if not just ask more questions.

float transTime = 1928.61582 // total seconds that something takes to happen
int minSec = 60 // number of seconds in a minute
int minutes = 0
float seconds = 0

minutes = transTime / minSec; // gives me the minutes
seconds = transTime % minSec; // gives me the seconds

cout << "The ammount of time is: " << '\n' // print out time
<< fixed << showpoint << minutes << " minutes " << setprecision(5) << seconds << " seconds" << '\n';

2. Bear in mind I've not actually compiled and checked this, and that I haven't written any C++ for years, but I think what you're after is:

Code:
```float transTime = 1928.61582 // total seconds that something takes to happen
int minSec = 60 // number of seconds in a minute
int minutes = 0
float seconds = 0

minutes = (int)(transTime / (float)minSec); // gives me the minutes
seconds = transTime &#37; (float)minSec; // gives me the seconds

cout << "The ammount of time is: " << '\n' // print out time
<< fixed << showpoint << minutes << " minutes " << setprecision(5) << seconds << " seconds" << '\n';```
What you have to do is explicitly cast minSec to a float to make sure that you don't lose the precision from the float before you've carried out the divide or mod operation. What you may also want to do is explicitly round up or down, but I'm not sure how to do this in C++.

I suspect declaring minSec as a float would have the same effect, and you wouldn't have to do the casts then.

Also, seconds has to be a float if you want to store the seconds to 5 decimal places. It isn't possible to store decimal or floating point values in an integer.

ac

3. hey thank you for your help but i figured out a solution.

I just added a var TMin to that dose nothing but hold the out out put of the minutes times minSec which gives me the amount of minutes in seconds then i just minus that from transTime which gives me the remaining seconds.

transTime = packetAmmount / transSpeed;
minutes = transTime / minSec;
TMin = minutes * minSec;
seconds = transTime - TMin;