-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Behavior of String::num
causes parse error for large float fields in Godot inspector
#93768
Comments
Theoretically speaking, there would also be the same problem on the smaller end, but maybe a bit less dramatic -- a value of Also: I don't think this issue is very important. |
It is important to me, doing a somewhat detailed space simulator, I need to enter values that routinely vary between e21 and e-21 pretty commonly for orbital calculation values and other math related values. And I care for the significant digits that I entered, even if they are after 18 zeroes behind a comma. This issue entirely prevents me from using the inspector, and at this point, the resource type for my custom resources becomes entirely unusable from the editor point of view. I have to resort to an external database for this. What bugs me is that while the ball bounces around while trying to cover every case with a magic solution, years pass by and not much changes, instead of just providing a toggle somewhere in the config or an annotation to the variable that just allows to switch between dumbed down floats for inspector or actual computer floats. I'd be happy even if accurate floats does not even have a slider with steps. Just allow us to write down valid floats, and keep them safe, that's pretty much it. |
I have a similar use case, I use CSV for said data. Of course this means it's no longer editable in the inspector |
I think the best solution is to use scientific notation for fields in the inspector, either by default or optionally with a hint. There is a function |
This is a bug indeed - if it's not a valid integer, it should try again as a float, especially since the field accepts floats. It seems that currently it uses
This is expected behavior, this happens due to the limitations of 64-bit floats. You can't reliably store an integer with a hundred digits in a 64-bit float. In fact, the limit is 2^53, so you can't even store 18 digits, you only get 15.95 decimal digits (almost 16 digits).
This is fixed by #47502, since now floats are converted to string using float literals.
That's a good idea, but we should wait until after the scientific notation function is fixed: #98750 |
Should not be related. |
I'm not asking to be able to store 3,0000000000000000000000000000000054, this would be unreasonable and not at all what I said. I;m asking to be able to store 0,0000000000000000000000000000000054. Which is storing 2 digits, after lots of zeroes. Which is the floating part about floating point, absolutely doable in a double. |
Tested versions
System information
Godot v4.3.beta (4ab8fb8) - macOS 14.0.0 - GLES3 (Compatibility) - Apple M1 - Apple M1 (8 Threads)
Issue description
1e100
into the field), but when clicking off the field this is converted into a long series of digits (e.g.10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469985856815104
). This is stored properly.I assume a similar thing would happen with
SpinBox
, but I haven't tested this.All of the individual steps of this (error for parsing absurdly large strings of digits; stringifying a float as a series of digits) make a lot of sense, but the result is that clicking on and off of a field changes the value, which feels like a bug.
I can think of a few possible solutions:
EditorSpinSlider
works so that clicking on and off of something never changes its value.Steps to reproduce
float
field (no range hint).1e+100
.10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469985856815104
.9223372036854775807
.Minimal reproduction project (MRP)
float-bug.zip
(v4.2.1.stable.official, I think)
The text was updated successfully, but these errors were encountered: