Godot Version
v4.5.dev5.official [64b09905c]
Question
Hi,
Just starting out with Godot Engine.
The following line of GDScript code produces two warnings and I don’t know how to fix it?
visualsClass.sprite_node.global_position = Vector2(1280/2, 720/2)
Warning(two times): “Integer division. Decimal part will be discarded.”
Hope someone can help me, thank you.
SS
Ok, I fixed it.
Changing it to:
Vector2(1280.0/2.0, 720.0/2.0)
erased the two warnings
SS
i see you solved it, thats great :3
FYI, integer division happens in (some?) coding languages, where when you divide 5/2 (or somethin thats not divisible by what yo u’re dividing it by) you would end up with 2. instead of 2.5. It discards the part that is in the decimal place, because you are only using integers, which only store whole numbers. at least, thats it to th best of my understanding.
So avoiding it with floats or doubles seems fine to me, though it’s been a while since I learned about integer division,s o i could be a little bit off. I think I remembered right though.