2
$\begingroup$

What is the precision of numbers in Blender? I am using Python scripting to adjust textures on a model, and need to define my own scaling algorithm. What precision?

If I put 0.0000000005 in the UI it ends up to 0.0, see animated GIF below.

enter image description here

$\endgroup$
6
  • 3
    $\begingroup$ if you are working with such small numbers consider changing the scale for the whole scene. $\endgroup$ – user1853 Feb 16 '16 at 14:54
  • 1
    $\begingroup$ Is that like 0.5mm precision against 1000km ? $\endgroup$ – batFINGER Feb 16 '16 at 15:19
  • $\begingroup$ afaik the precision goes only at 5 digits. (A problem if you need to work with factors 0-1.) I see that in vectors etc but not sure for image/texture/uv where 0-1 factor is used a lot. Could be that image knows better but the node does not.. $\endgroup$ – o.g. Feb 16 '16 at 15:23
  • 1
    $\begingroup$ sorry, the q is about ui or you have a problem with the outcome? the Ui is another case. if u enter "pi" it will display 3.1415 but actually the number is interpreted correctly inside.. $\endgroup$ – o.g. Feb 16 '16 at 15:26
  • $\begingroup$ I need to get understanding on the limitations of using scaling... I don't think I will get into that problem, but is the UI/python mapping the same, so it will only get max percision of 5 digits? But when I inspect the Python values for scale items, they are <class 'float'>. So I'm curious if they are just truncated in the UI, but actually stored internally as floats? $\endgroup$ – pjotr_dolphin Feb 16 '16 at 15:35
2
$\begingroup$

32-bit Floating point representation offers approximately 7.2 decimal digits of precision (7.2 = 7 + 1/5), https://en.wikipedia.org/wiki/Floating_point

Blender limits that to 7 digits. Absolutely safe is to have your number's fraction and integral parts not exceeding 7 digits in total.

If your numbers exceed these limits, the rounding error may be seen, for example, if you set scale X for the default cube to 123456789, it will turn to 123456792.

There is no good way to observe floating point values in the UI, maybe you can print them with Python, as that will avoid Blender's UI conversions.

You can experiment with floating point rounding effects using my online C++ test http://cpp.sh/9pv2l

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.