1

Whenever I enter the 11/12 digit number that I need for one of my projects into the value input of any (shader) node, Blender lowers the number.

For example, I've tried to input the number '12345678910', an 11 digit number and gotten '12345678848' instead. I know that Blender often rounds and hides the displayed numbers sometimes, but given that the number is completely different, I'm not sure that's the case.

If it is a bug, then it's been there for a while. I checked and it was present in Blender 2.81 as well. I've also replicated the issue on Mac and Windows systems. You can replicate it by inputting a 10 or higher digit number into a value node (in the Shader Editor).

I want to figure out what's going on and how to fix it. Any help would be very appreciated. Thanks!

Exporer
  • 13
  • 3
  • 4
    Yep it's only possible to ensure 8 digits of precision in the floating point values. Maybe you can try to achieve it by other means, it seems like an oddly high and yet precise number to work with. What were you trying to do ? – Gorgious Feb 10 '22 at 06:59
  • Thanks for the great answers @Gorgious and Gordon Brinkmann! Knowing that there's no way to get around this, I'll just stick to my current method.

    I'm making a barcode shader, and instead of someone inputting 12 digits of values (https://imgur.com/a/X00oY78) in different inputs, I wanted them to just put be able to put it all in 1 input.

    I then had the issue described above and adapted to a system where they could input the first and last 6 digits instead, and that's what I think I'll keep using. (https://imgur.com/a/tvnTNs1)

    Thanks, everyone!

    – Exporer Feb 10 '22 at 07:51

1 Answers1

7

As far as I know, it is not a bug and thanks to @Gordon's comment, I dig up a bit more in the subject and figured out that it's actually more complicated that what I thought it was.

What is happening here is, as @Gordon and @Gorgeous said, a Floating point precision problem.

Float numbers are stored as bits with 3 parts : the sign bit, the exponent bits and the mantissa bits. The mantissa bits (sometimes it can be called a sinificand) are the ones that give the actual precision to the number while the exponent bits tell how big the number is. Basically, the bigger the exponent is the lower the precision is going to be.

It's explained by this chart

enter image description here

which I took from this page.

The second column indicates the range of the represented number and the 4th column gives the amount of precision you'll get if you represent that number as a float, if the difference between two numbers is less than the number in that column then they will be considered to be the same.

You can have an exact precision for whole numbers up to $16777216$ (which is $2^{24}$) but if you go beyond that, whole numbers will not be represented accurately anymore. You can try typing 16777217 for example and you'll see that it'll get "round down" to 16777216.

And contrarily to the previous answer I wrote 12345678910 is not the larger number Blender can handle, it can go as far as 340282346638528859811704183484516925440 (it will be considered as inf) but as explained earlier, accuracy will suffer a lot at that range.

Gordon Brinkmann
  • 28,589
  • 1
  • 19
  • 49
mqbaka mqbaka
  • 3,036
  • 7
  • 22