[Qt-interest] Why 1/255 is 0 ?
Alexandre Beraud
aberaud at infflux.com
Wed Oct 13 16:18:46 CEST 2010
Hi,
The container (c) may be double, but my guess is that 1 is considered as
an integer by the compiler, thus 1/255 is 0, converted to double which
is still 0.
Once again, this is NOT a Qt related question.
Regards,
Alex
Le 13/10/2010 16:11, Hannu Shemeikka a écrit :
> Hi,
>
> Could someone explain me this:
>
> double c = 1/255;
>
> and c is 0 after watching it in debugger. It should be 0,003921569.
> I tried float and few others but no success.
>
> The real thing where I need that division is qPow((i/255),(j/1)); //
> i<255 and j<8
>
> What am I missing here? I'm using Ubuntu 10.10 and Qt 4.7
>
> - Hannu
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list