[Qt-interest] Why 1/255 is 0 ?

Chetan Jain chetankjain at gmail.com
Wed Oct 13 16:17:15 CEST 2010


Hi,
Check this link:
http://developer.qt.nokia.com/wiki/Integer_Division_gives_0
br
Chetan
On Wed, Oct 13, 2010 at 7:41 PM, Hannu Shemeikka <hps at shemeikka.org> wrote:

> 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
>



-- 
Best Regards,
Chetan K Jain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101013/4b53a6cd/attachment.html 


More information about the Qt-interest-old mailing list