Community
Bifrost Forum
Welcome to the Bifrost Forum. This is the place for artists using Bifrost to ask and answer questions, browse popular topics, and share knowledge about creating effects procedurally using Bifrost. You can also visit the Bifrost Community on AREA to download an array of ready-to-use graphs, read Bifrost news and updates, and find the latest tutorials.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

number_to_string cannot handle "float" correctly.

3 REPLIES 3
Reply
Message 1 of 4
g2m.agent
318 Views, 3 Replies

number_to_string cannot handle "float" correctly.

maya_lI6ED7ejhO.png

I know that there is always an accuracy problem, but I prefer the behavior of the node to be consistent with the value I see.

Labels (1)
3 REPLIES 3
Message 2 of 4
Grahame_Fuller
in reply to: g2m.agent

This is how floating-point values work -- it's not specific to Bifrost.

 

Floating-point values cannot represent all decimal values exactly -- there are gaps. In this instance, .370000005 actually is the decimal representation of the closest floating-point value to .37. In the UI, the float value is rounded for display but the string is not.

 

If you wanted to, you could use the string manipulation nodes to truncate that string to the number of decimal places you want. Rounding is also possible, but a bit trickier. However in either case, the string would no longer be the exact decimal representation of the actual float value that was converted to a string.

 

Hope that helps,

gray


Grahame Fuller
Learning Content Developer
Message 3 of 4
g2m.agent
in reply to: Grahame_Fuller

How float work is not important to the user.
I think that since users convert float into text, its meaning is by no means for precise calculations, but just for "show". for human to read, not to calculate. what is the point of showing its full accuracy? If you want to check the float precision, wouldn't it be more reasonable to put it in watchpoint.
I strongly recommend modifying how number_to_string works. I really can't understand the design intent of this node and the working scenario.
Message 4 of 4
Grahame_Fuller
in reply to: g2m.agent

I beg to differ -- how floats work is sometimes very important to users.

 

Comparisons are just one example (see Comparing Floating Point Numbers, 2012 Edition). This is why there is an almost_equal node.

 

The number_to_string node is just one of a set of basic conversion nodes for generic use. One possible use is to store string properties to help with debugging. In such a scenario, knowing that a value is actually 0.370000005 and not 0.37 might be critical.

 

Cheers,

gray


Grahame Fuller
Learning Content Developer

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report