Incorrect results when doing division with variables

This code ^^

Returns this vv

width = 1000
selImg.width = 255
height = 1000
selImg.height = 255
((width / selImg.width) * selImg.height) = 900
((height / selImg.height) * selImg.width) = 900

Obviously somethings going wrong with the math as 1000/255*255 should result in 1000.

How do I fix this?

(I have console results but I can only use one image in each post)

Keep in mind that int values can only hold whole numbers.

So this:

int x = 3 / 2;

Will print out 1 instead of 1.5.

You can fix this by converting one of the numbers to float first:

float x = float(3) / 2;

By the way, instead of posting an image of your output, please try to paste a MCVE directly in your message. You should also try breaking your calculations down into multiple lines to understand what’s going on better.