[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Question about "math" in Qt
From:       Wolfgang Westphal <wolfgang.westphal () gmx ! de>
Date:       2004-12-24 13:18:59
Message-ID: 200412241418.59802 () wolfgang-westphal ! de
[Download RAW message or body]

Thiago Macieira schrieb:
> Carsten Niehaus wrote:
> >And how do I know the number of digets? The expected numbers are
> > anywhere between 1.0007 and more than 200.
>
> power = 1e-6;
> while (power < num)
>   power *= 10;

Why not:

power = pow(10, ceil(log10(num)));

That should do the same without the arbitary restriction power >= 1e-6.

> Then log10(power) indicates the number of digits to the right of the
> period.

Not sure what you mean here. log10(power) tells you the decade num is 
found in. For log10(power)>0 and log10(power)!=log10(num) it's the 
number of digits on the left side of the period.
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic