returning a long decimal number

I am trying to find the percentage of white pixels in an image:

I have the total pixel value and the white pixel value and my code is:

long double percentWhite = soundAmount/totPix*100;

my problem is that the percentWhite variable is always returned as 0. If I print all three values to the console I get for example

total pixels is 786432
sound amount is 5375
percent white is 0

I just can't figure it out, please could someone help?
Thanks
This is integer division. When you divide integers, you get integers. so 1/2 = 0, 3/2 = 1 and so on. You have to convert either of your ints to a double. One way to do that is to multiply it by a double : long double percentWhite = 1.0*soundAmount/totPix*100;
Ahhh, I see! Thank you ever so much, it is working now :D
Topic archived. No new replies allowed.