godot: Decimals() is not functioning properly
Godot version: 3.0.6.stable.official.8314054
OS/device including version: Windows 10
Issue description: The function Decimals returns 0 even when I have a decimal number.
information in Godot’s API reference:
float decimals ( float step )
Returns the position of the first non-zero digit, after the decimal point.
# n is 2
n = decimals(0.035)
Steps to reproduce: code used:
func _ready():
var temp_wind = 0
randomize()
wind_speed = round(rand_range(50, 100)) #get a rounded number between 50 and 100
temp_wind = wind_speed / 2 #divide by 2, so all odd numbers should have 1 decimal now
if decimals(temp_wind) == 0:
wind_speed = -wind_speed #is always called even if temp_wind is an x.5 value
Minimal reproduction project: Debug Project.zip
In order to easily reproduce just relaunch project over and over untill you get an odd value, or just assign wind_speed directly with a non random odd number. In the debug project I’ve made sure to print the result in the debug window yielding:
running cmdline: "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" "--path" "C:/games/Projects/Debug%20Project" "--remote-debug" "127.0.0.1:6007" "--allow_focus_steal_pid" "396" "--position" "448,240" "res://scene.tscn"
** Debug Process Started **
OpenGL ES 3.0 Renderer: GeForce GTX 960/PCIe/SSE2
**25.5 contains no decimals**
** Debug Process Stopped **
I hope this information suffices to look into the issue.
Thanks in advance!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (10 by maintainers)
@akien-mga Done, how’s this? I left it as a separate commit from my “add step_decimals as an alias and fix the C# method” commit (by the way, does not break compat anymore).
Output: