Floats are consistently rounding to integers

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

This is Godot 3.

I’m doing some float work, and it kept coming back as an integer rounded down.


Returns 0

print (float(4/3) == float(1.0))

Returns True

print(“%1.1f” % (18/10))

Returns 1.0

print(“%1.1f” % 1.8)

Returns 1.8

Curious as to what I’m doing wrong or how to work around this issue.


:bust_in_silhouette: Reply From: Diet Estus

Try 1.0/2 or float(1)/2.

Division using only ints will return an int. If one of them is a float, the result will be a float.