[Kstars-devel] branches/KDE/3.5/kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Sun Aug 7 22:26:04 CEST 2005
Hi Heiko,
> Try something like round(), there should be a function like this somewhere
> in the math-library. If there is none: try int(d+0.5), in order to
> implement round.
>
No, we don't want a round() function here. If the value is 13.6, we want the
integer part to be 13, not 14. Again, the problem is:
double x = 13.00000000000;
int i=int(x); // i == 12, *not* 13!
int j=int( float(x) ); // j == 13
I don't know why it works. I would think that the double-precision value
would be less susceptible to roundoff error, but it appears that casting as
float before taking the int solves the problem.
--
KStars: KDE Planetarium
http://edu.kde.org/kstars
More information about the Kstars-devel
mailing list