Math is broken

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By scooty

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

I think you produced the best title in the history of this forum. :slight_smile: 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)

DaddyMonster | 2021-10-23 10:17

:bust_in_silhouette: Reply From: pouing

Please consult the similar question: https://forum.godotengine.org/4588/1-4-0-not-25-why-isnt-division-working-in-gdscript

:bust_in_silhouette: Reply From: Bengt Söderström

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