Bug Reports: Floating point precision bug handling #60

Closed
Iliya Katushenock wants to merge 1 commits from mod_moder/blender-developer-docs-fork:triaging_floating_point_error into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 75 additions and 0 deletions
Showing only changes of commit 49ac1909f8 - Show all commits

View File

@ -0,0 +1,45 @@
# Floating point error
## Explanation
Every time user are operated by non integer values in blender is floating
point values of 32 bit. Here is some notes about such values:
1. Order of operations and its type is matter. `A + A + A` is not `A * 3`.
2. All floating points values are decimal representation of binary real number
and binary exponent value.
3. Just like you can not write `10 / 3` in limited decimal number (`3.333...`),
you can not represent `1.1` as floating point value without very small but
still existed fractional part: `1.10000002384185791015625`.
4. Just to do not mess UI by all this, usually not really matter, details,
Blender draw floating point values with fixed number of digits after dot.
3. Comparison for equality is something that users should not do at all. If
this values are not typed by user, but result of calculations, comparison
going to be fail in a lot of cases. Sometimes blender can provide epsilon
setting to avoid this error.
4. Fix of floating point error are not trivial. For example, does this should
requers infint number of digits for `3.333...`? Or mathematical expressions
should be stored as value and comparison should be kind of subtraction of
such expressions and next simplification by mathematical rules be performed?
5. Using of dooble will increase execution time, memory usage. Replace of all
floating point numbers in blender will be far expensive refactor.
## For bug triaging
Bugs, that related with floating point precision are well defined and can be reported as:
- Graphical artifacts in shader.
- Incorrect result of conditions.
- Shaking of objects on large coordinates.
- Additional fractional part in result of symmetrical operations.
- Logarithmic notation of value in field (`3e-10`).
But even so, this is not a bug. Most often the error is caused by the user or
can be corrected by changing the math.
## References
Some links to check:
- More detailed learn about float: <https://en.wikipedia.org/wiki/Floating-point_arithmetic>.
- Online view of floating point value representation: <https://www.h-schmidt.net/FloatConverter/IEEE754.html>.

View File

@ -69,6 +69,7 @@ template for them.
- Complete report, but performance - Complete report, but performance
- Complete report, but corrupted mesh - Complete report, but corrupted mesh
- Complete report, but dependency cycle - Complete report, but dependency cycle
- Complete report, but floating point precision
- Unsupported graphics card or driver - Unsupported graphics card or driver
- Blender doesn't run / crashes - Blender doesn't run / crashes
@ -422,6 +423,35 @@ latest Blender:
> but these cases are mostly known and the solution for them requires bigger > but these cases are mostly known and the solution for them requires bigger
> design considerations which is outside of the scope of the bug tracker. > design considerations which is outside of the scope of the bug tracker.
### Complete report, but floating point precision
**Example:** [\#121793](https://projects.blender.org/blender/blender/issues/121793),
[\#122181](https://projects.blender.org/blender/blender/issues/122181),
[\#122046](https://projects.blender.org/blender/blender/issues/122046)
**Action:**
- Close the report.
- Change the `Status >` label to `Status > **Archived**` (a bot
should do this automatically - but only visible after a manual refresh
of the page).
> NOTE: **Message Example**
> Thanks for report. Core of the issue described here is the floating point
> precision issue. Some description of such issues:
>
> 1. Math in computer is not the same math that you might learn in the school.
> There is the set of some limitations and specifics that cause different result
> in compare with your expectation.
> 2. Range of enough good value precision is around 5 digits around dot.
> 3. UI draw only very small range of digits in fractional part just for
> compactness. If you want to see real representation of the value, you need
> to use python.
> 4. Floating point value is how computers handle real number today, and
> there is no way to fix issues related with that in general mean.
>
> See <https://developer.blender.org/docs/handbook/bug_reports/floating_point_error/> for more details.
### Unsupported graphics card or driver ### Unsupported graphics card or driver
**Action:** **Action:**