ashstampede
Programmer
I am attempting to create a timer using the CPU ticks the, the real problem is this is an abstract class And i dont know how the authurs TIMER works but it returns a float.
I have then created a timer counter, that track the time since the function was last called. The problem is it never evaluates true in the if statement
the code never gets inside the if statement and example of the data in curretSecondsPassed
float currentSecondsPassed 1.9555557e-006
float currentSecondsPassed 2.2349209e-006
float currentSecondsPassed 2.3466670e-005
float currentSecondsPassed 0.00010113022
that final value happens when the currentSecondsPassed goes over 9.9999999exxx baically its max number.
so generally the numbers are bigger than zero in float form, but when i cast at int t = currentSecondsPassed; t is always equal to 0 after that line. why?
I am thinking the float is to large for the int? but should it not simply take the 1 and forget about the .xxxxxxxxxx
I tried static_cast<int> as well with no luck, any help to this? thanks in advance
I have then created a timer counter, that track the time since the function was last called. The problem is it never evaluates true in the if statement
Code:
currentSecondsPassed += timerEngine->Timer();
//when the current milli of a second equals one add to a second
int t = currentSecondsPassed;
if(t > 0 )
the code never gets inside the if statement and example of the data in curretSecondsPassed
float currentSecondsPassed 1.9555557e-006
float currentSecondsPassed 2.2349209e-006
float currentSecondsPassed 2.3466670e-005
float currentSecondsPassed 0.00010113022
that final value happens when the currentSecondsPassed goes over 9.9999999exxx baically its max number.
so generally the numbers are bigger than zero in float form, but when i cast at int t = currentSecondsPassed; t is always equal to 0 after that line. why?
I am thinking the float is to large for the int? but should it not simply take the 1 and forget about the .xxxxxxxxxx
I tried static_cast<int> as well with no luck, any help to this? thanks in advance