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

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


i'm bored of this kind of pb. We should perhaps have choose an integer storage
for the values as i did on the website.

Quoting Janek Polak <benetnash@xxxxxxxxxxxxxx>:

> Dnia Tue, 1 May 2007, Nicolas Adenis-Lamarre naskrobal
> >  Janek Polak a écrit :
> > > Today morning I've invented that this floating point differences can be
> > > removed by changeing (replay_time < highscore_time) to (replay_time -
> > > highscore_time < -0.01). I'm not perfectly sure if it works, but this
> > > solution looks fine. I left comment in case someone invent something
> > > better.
> >  i found a nice feature of sqlite,
> >  it has not a lot of function, however, it allows to add news !
>
> >   sqlite3_result_double(i_context, (double)((int)(v_value)));
>
> It is not working - it truncates 23.0 to 22.0 and so on - from numbers
> witout decimal digits it substracts 1. I think that issue may be caused
> by some floating point errors. Look at this:
>
> testowe$ cat x.cpp
> #include <iostream>
> using namespace std;
> main()
> {
>
> 	double x = 23.456;
> 	printf("%2.20f\n", x);
> 	printf("%2.20f\n", 100 * x);
> }
> testowe$ ./x
> 23.45599999999999951683
> 2345.59999999999990905053
>
>
> This 23.456 will be truncated by your function to 2345.5
> My nasty workaround is:
>
> sqlite3_result_double(i_context, (double)((int)(v_value + 0.0000001)));
>
> On the other hand we could round number with:
>
> sqlite3_result_double(i_context, floor(v_value + 0.5)));
>
> Anyway I've just commited first workaround and added xm_floor to both
> times:
>
> xm_floor(h.finishTime*100.0) > xm_floor(r.finishTime*100.0))
>
>
>





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