Notifications
Clear all

[Closed] 0 vs -3.8147e-006

In one of my script I need to know if the object Z position is equal to 0, but, sometimes max prints

obj.pos.z = 0.0

, sometimes –

 obj.pos.z = -3.8147e-006

.

I use this code for testing if the obj position is equal to 0

if obj.pos.z == 0 or (matchPattern (obj.pos.z as string) pattern:"*e*") then... else...

This not work:

close_enough (-3.8147e-006) 0 1

Is there another way of detecting that -3.8147e-006 is 0?

5 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

this is just wrong…

if obj.pos.z == 0 or (matchPattern (obj.pos.z as string) pattern:"*e*") then... else...

it might any number in e pattern…
do something :


if abs (z)  < 0.000001 do ...

Thank you, denisT.

by the way… you can find my roundFloat function on this forum. it’s what i use instead of the close_enough

 PEN

Yes, PEN. I found it, but I need only to know if the value is zero or not, so I start using obj.pos.z < 0.000001.