Jump to content

VEX Modulo Operation giving incorrect results


DeeLan

Recommended Posts

I've got a Wrangle Node (set to Detail) with some stuff in it. Amount that is a simple Modulo Operation - "offset%spacing". Now obviously if offset is a multiple of spacing then "offset%spacing" should equal 0. Problem is, most of the time it definitely does not equal zero. I've found that when spacing equals certain values (0.5 for example) then the result is as it should be. However most of the time I'm getting errors. Some are small (2.08616e-07 is one such value) but others have been as big as "spacing" itself. For example, at the moment offset and spacing are 27.6 and 0.4 respectively. When I put those values through a calculator I get 0 (as I should, because 27.6 is a multiple of 0.4). However Houdini simply gives me 0.4 I've gone a done the math by hand (well really by calculator) for a bunch of combinations and while they all return 0, Houdini still gives an incorrect value.

Please Help! I have absolutely no idea why this is happening.

Link to comment
Share on other sites

so I'm still getting issues even when I convert to integers. Its really weird, but I'm finding the only way to only way to get the correct results is to decrease the accuracy. For example, if I multiply (and then redivide) my float by anything above 10^5, then I get incorrect results again, whereas 10^4 seems to get it right all the time (so far). So even if I have a value to 6 or 7 decimal places, its better to just multiply by 10^4 and lose those last few digits. Its just so odd that using less accurate values yields the proper results.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...