Why does the animation not play if you type 60 instead of 60.0

 On the division here I forgot to type 60 with a decimal like 60.0.  There was no error in the compiler/output/debugger and the animation did not display.  Why not?  That's not very helpful

var duration: float = rich_text_label.text.length() / 60

 tween.interpolate_property(rich_text_label, "percent_visible", 0.0, 1.0, duration)


  • Razoric replied

    returns an integer (no decimal number)


    is an integer (no decimal number.) As they are both integers, the compiler treats this as an integer division, meaning it gets rid of the decimal part. So you get either 0 or 1, even though you then store it in a float after the fact.

    It is a logical error (the coding logic does something unintended), but not a coding error. The compiler can't read your mind, after all, and this is legal as far as it is concerned.

    One of them has to be a decimal point for it to be a floating point division.

    1 love