Author Topic: Bot-Making Help  (Read 899 times)

MarvinMan

  • Automation Expert
  • Experienced Member
  • ***
  • Posts: 236
  • Likes: +4/-0
    • View Profile
Re: Bot-Making Help
« Reply #30 on: April 02, 2016, 07:45:09 pm »
I was wondering about that the other day too. I'm sure it used to output 0 when the input was exactly zero. In the end, I ended up adding -0.01 to the input to stop it outputting a 1 for zero input.

PressureLine

  • XFM Developer
  • Administrator
  • Experienced Member
  • *****
  • Posts: 192
  • Likes: +4/-0
    • View Profile
    • Rawbots Club Forums
Re: Bot-Making Help
« Reply #31 on: April 02, 2016, 10:05:56 pm »
Thanks for the heads up PressureLine. I have a question: Isn't the sign function supposed to output a 0 if the input is 0? Mine is outputting a 1 for some reason.

Here is the code:

Code: [Select]
public static float Sign(float f)
{
    return ((f < 0f) ? -1f : 1f);
}

So in theory you are correct, doing SIGN(0) should output 1. But, remember floating point math. XFM 0.5 shows 3 decimal places, but the maths runs at 6 decimal places, so there could be something there.
"Never assume that anything you've never seen before is benign. Most particularly not something that says 'MARINES' on it."