about division truncation in godot (math problem) #7284
Replies: 4 comments
This comment has been hidden.
This comment has been hidden.
-
Use a floating-point number as one of the operands: |
Beta Was this translation helpful? Give feedback.
-
Hey there! I think you have an issue in your code somewhere. The only way for To explain, in Godot there is a difference between an integer division and a floating point number division. If you divide two integers you get an integer. If you divide an integer and a float, or two floats, you get a float. You seem to operate under the assumption that in your code you have floating point numbers. But that doesn't seem to be true. You can ensure that you operate on floats by casting your values. E.g. |
Beta Was this translation helpful? Give feedback.
-
See documentation |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the project you are working on
in godot 3.5.2
in music game , i need to calcuate Timing of each beat
for example
music bpm:120 (120 times pre minute)
Timing of each beat = 60.0/120.0=0.5 (math calcuate)
but when cal in godot , this always return 0
how to solve this problem , when I need small float / big float , then get the 0.x like value?
this is a math problem
Describe the problem or limitation you are having in your project
in math calcuate
Describe the feature / enhancement and how it helps to overcome the problem or limitation
give some math helps about things like 60.0 / 120.0 = 0.5

but 60.0 /120.0 get 0.0 in godot
I need this 0.5
how to get it.
if engine coder can't resolve this , how to use * math and other rules of arithmetic to get this 0.5?
MicoSoft's windows's calcuate can return true value , how to get this in godot?
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
no
If this enhancement will not be used often, can it be worked around with a few lines of script?
still in think (another math calcuate to get this / get a true float in godot)
Is there a reason why this should be core and not an add-on in the asset library?
nothing
Beta Was this translation helpful? Give feedback.
All reactions