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

Reece Dunn msclrhd at googlemail.com
Wed Oct 13 16:15:27 CEST 2010


On 13 October 2010 15:11, Hannu Shemeikka <hps at shemeikka.org> wrote:
> Hi,
>
> Could someone explain me this:
>
> double c = 1/255;

That is an integer division that is rounded to the nearest whole integer.

Try:

    double c = double(1)/255;

and:

    int i = 1;
    double c = double(i)/255;

HTH,
- Reece



More information about the Qt-interest-old mailing list