I know that floating point number precision can be a bit off, but I am confused why a float from a Vector3 would be any different from a standard float. I was trying to work out why my 1 became a 0, and my 12 became 11 when converted from float to int and after a bit of playing around I found that the problem was caused by Vector3.
The following code demonstrates the problem:
func _ready():
# Wrong result:
var test_point = Vector3(3.8, 3, 7.5)
var i = test_point.x / 3.8
print("i as float: ", i)
var int_i = int(i)
print("i as int: ", int_i)
# Right result:
var j: float
j = 3.8
j = j / 3.8
print("j as float: ", j)
var int_j = int(j)
print("j as int: ", int_j)
I get the following output:
i as float: 1
i as int: 0
j as float: 1
j as int: 1
I am using Godot 3.3.2.stable on Linux 64-bit