var/oldWidth = 28
var/newWidth = oldWidth * 1.5
var/XscaleFactor = (oldWidth - 1) / (newWidth - 1)
for(var/count_x = 1; count_x <= oldWidth * 1.5; count_x++)
var/xVal = (count_x - 1) * XscaleFactor + 1
var/roundedX = round(xVal)
usr << "[count_x] gives an xVal of [xVal] with a roundedX of [roundedX]" //DEBUG TO CHECK THE NUMBERS
if(xVal != roundedX)
alert("Not a whole number")
usr << "Not a Whole Number"
else
alert("A whole number")
usr << "Whole Number"
Problem description:
I decided to post here before I post a bug report as my code may be wrong.
The above code should loop 42 (28 * 1.5) times and call alert("A whole number") twice. Once when count_x is 1 and when count_x is 42
This is because at count_x = 1, xVal = 1 and at count_x = 42, xVal = 28. Which is true, but the if statement stops working for count_x = 42 for some reason. I put in a debug line to check the values and the roundedX and xVal are both exactly 28 when count_x is 42, so it should call the whole number but it doesn't...
Any input?
EDIT: It's basically saying 28 != 28 and I have no idea why...
Maybe an internal rounding error?
I get Nay here.
But if I compare with the whole number.
I get YAY here.
Is this a bug?