0 votes

I have the simple code print(3 / 100) and it outputs 0. What is wrong with this? I'm so baffled.

in Engine by (31 points)

I think you produced the best title in the history of this forum. :) The answers below / link to answers are spot on. But for a bit of fun on a semi-related tangent, try putting this into your code somewhere and running it:

printt("Does math work?", 0.1+0.2==0.3)

2 Answers

0 votes
by (68 points)
+1 vote

Godot assumes you want an integer if you don't add a decimal point:

print(3/100)
print(3.0/100.0)
print(3.0/100)
print(3/100.0)

Results:

0
0.03
0.03
0.03
by (64 points)
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.