0 votes

Hi What would print((300/500) ) show on the screen ?
I'm getting 0.
Am I doing something wrong ?

in Engine by (114 points)

1 Answer

+1 vote

That's called "Integer division". Because both numbers are integers, the result (0.6) is cast to integer as well, which results in 0.

If you want a float answer, at least one of the operands needs to be a float: print(300.0/500) or even print(float(300)/500)

by (20,917 points)

Thank you so much Love your tutorials !!!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.