Weird Division Bug
Monkey Forums/Monkey Programming/Weird Division Bug
| ||
I did not put this in the bug section cause I it might be intended to act like this to prevent something from going wrong or for other reason. When I try to do this division I always get 1 scale=DeviceWidth()/img.Width() But If I do this, it works fine: w=DeviceWidth() scale=w/img.Width() I was just wondering why is this happening? |
| ||
What are the definitions of w and scale? |
| ||
floats I also tried to do is: DrawText "scale= "+DeviceWidth()/img.Width(),x,y with the same result |
| ||
Right, so: scale=DeviceWidth()/img.Width() That's Float = Int/Int. In other words, you're doing an integer division and the result will be an integer which is then assigned to a float. w=DeviceWidth() scale=w/img.Width() That's Float = Float/Int, so the division produces a float result. |
| ||
LOL. I feel stupid not to notice that. Thanks |