Skip to content

exported float is rounded down #109838

@jan-kapoli

Description

@jan-kapoli

Tested versions

  • Reproducible in: v4.4.1.stable.official [49a5bc7], v4.4.stable.custom_build [4c311cb]

System information

Godot v4.4.1.stable - Debian GNU/Linux 13 (trixie) 13 on Wayland - X11 display driver, Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce MX150 (nvidia) - Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz (8 threads)

Issue description

When setting an exported float variable to a small value via the editor it gets rounded down to 0.0. This happens even when the Default Float Step would allow for such small increments to be entered.

Steps to reproduce

  1. Set the Default Float Step (Editor / Editor Settings... / Interface / Inspector / Default Float Step) to 0.000001 (that is 1×10^-6).
  2. Attach a script to a Node.
  3. Enter the following line: @export var f: float
  4. Set the value of f to 0.000001 through the editor.
  5. Observe how when hovering over it, it shows as 0.00000099999306. (What format is this? IEEE 754 32-bit and 64-bit formats store 0.0000009999999974752427078783512115478515625 and 0.000000999999999999999954748111825886258685613938723690807819366455078125 respectively)
  6. Run the scene. The value of f can be checked via the following lines:
    print_debug(f) and print_debug(f == 0.0)
    They return 0.0 and true respectively.
    This is unexpected. I would expect 0.000001 or 0.00000099999306 and false respectively.

Additional steps to verify that it only happens to values set via the inspector:

  1. Enter the following line var g: float = 0.000001.
  2. Check the value of g via the following lines:
    print_debug(g) and print_debug(g == 0.0)
    They return "0.00001" and "false" respectively.

This shows that the rounding happens to values set through the inspector.

Minimal reproduction project (MRP)

Bug.zip

Note that when editing the file Node.tscn, the line f = 0.000001 is nowhere to be seen.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status

For team assessment

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions