Re: [xmoto-dev] svn 1404 : merged benetnash with trunk

[ Thread Index | Date Index | More lists.tuxfamily.org/xmoto-dev Archives ]


Dnia Wed, 2 May 2007, nadenislamarre@xxxxxxx naskrobal
> benenash :
> 
> To avoid this pb,
> i wrote this in std::string App::formatTime(float fSecs)
>     /* hum, case, in which 0.9800 * 100.0 => 0.9799999*/
>     if(((int)(nHres * 100.0)) < ((int)((nHres * 100.0) + 0.001))) {
>       nH = ((int)((nHres * 100.0) + 0.001));
>       nH %= 100;
>     }
> 
> however, we should write funtions called :
> 
> float timetoFloatTime(int i_minutes, int i_seconds, int i_seconds);
> void  timeToIntTime(float i_time, int& o_minutes, int& o_seconds, int&
> o_hundreaths);
> 
> which assumes :
> i_minutes : i_seconds : i_seconds >= float
> to FIX definitively this pb into 2 functions.
> 
> What do you think about this ?
> 
> Nicolas
> 

The idea to keep everything in db as integers schould resolve this
problem. Another idea is to create wrapper around float such a
xmTime or something which will keep time internally as a double and
overload comparsion operators to avoid floating point problem. The
easiest solution is to use round(100 * x) or floor(100 * (x + 0.5))
everywhere time is compared or even used. 

On the other hand if this problem exists only in database query we can
check not if (replay_time < highscore_time) but if (replay_time -
highscore_time < -0.01). This will keep querys simple, but won't solve
problems outside database.

Best Regards
Janek 'benetnash' Polak




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/