You have casted y1 as a double before casting it again to a long. the value of x isn't the "floor" value but a rounded value for floor.
Same logic would apply with casting integers and floats. float x = (float)((int) 1.5) will give a different value to float x = 1.5