Integer Division Warning

Godot Version

godot 4.4.1

Question

Is there no way to do actual integer division so that I don’t get this damn warning about integer division? It’s actually driving me crazy and I don’t want to see warnings about it when I intend for integer division to be done. Since gdscript is python inspired I tried to see if // is a thing but it’s not. Anyone know how to fix this without straight up getting rid of all warnings?

1 Like

hey there that’s my first time to help someone in godot forum, use // for integer division in GDScript. If you want a float, make sure one number is a float like a / 2.0. This removes the warning without disabling all warnings.

can u help me in my game too pls?

Hi, in GDScript, // actually causes a parse error because only / is a recognised operator.

To do integer division, I usually do something like int(float(x) / y) which looks pretty disgusting but at least it makes the engine happy.

If you really want to do integer division without any extra syntax you can suppress the warning by pressing the “ignore warning” button next to the message, this will add a matching @ignore_warning line.
Alternatively, you can disable all warnings about integer division in the editor settings.

If you need help yourself, please create a separate topic for it, it helps organise the forum

1 Like

Didn’t know about the line specific ignore warning, this is what I wanted. Thank you!

hi there i made a forum as u said and sorry for spreading wrong info i tried asking chatgpt

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.