anyone know the array issue,can't print right.

i have a float array,and i print the float array using foreach,at the same time ,i print the min value of the float array,but the print shows,the min value of array do not contain in the array ,no one print match the value ,as the picture show,was the node"min of the float array" problem?
screenshot-20240626-225546

What’s wrong with it? Seems fine. The min value is 750 - or do you mean the precision of the float? Because that’s fine, too.


Perhaps clarify what values you expected?

it is the pircture shows,it seem what the node"min value of float array"prints is a new varable is not belong the array

It’s a floating point error, it’s unavoidable. Please check the link above.

so the best way to use this kind of float type is truncate the float value,then they are extract the same ?

It really depends on what you want to use them for. The general idea about float imperfection is to ignore it until it causes issues - then you manage it. In your example, it does not seem to matter so far. There may be no need to trunc or round anything. Give us an example usage!

When comparing floats, rather than checking whether they’re equal you’d instead:

image

Give it some wiggle room.

i want to check if those two value are equal,then i use branc to do something stuff

1 Like

As above then.

ok,it seems the this is the best way to do comparision on them,thanks

1 Like

image

1 unreal unit = 1cm. So that 31 is most likely nanometres or something. That’s enough precision for a lot of use cases. May not be good enough if you’re making a large procedural city or a space game, though. The errors will eventually add up over time. Then you handle it.

Snapping floats / vector can be handy:

image

In a nutshell:

Good luck!

2 Likes

thanks very much

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.