3

So I was working on Nex Robotics's Firebird V,
Was doing some graph traversal thing...

And was breaking my head for 28hrs... I was passing the bot an structure of direction and no. Of times it had to take that direction...

something like for(int i=0; i<dir.times;i++)

And after 29 hrs I realized it also had negative values...

that effing abs() was missing 😫

Comments
  • 1
    *insert comment about utility of type systems in preventing errors like this*
  • 0
    Ofcourse I do... But finding this thing in 2000+ lines of code 😕
  • 1
    @TejeshJadhav that's the point
    With well enforced types the compiler would catch this mistake immediately doesn't matter how big your codebase is. Saved my ass quite a few times.

    If you're using embedded C crank up the warnings to max so that mixing signed and unsigned integers would trigger a warning at least in general (not sure if C warns you, C++ compilers do).

    (If you're using floating point numbers then eh).
  • 1
    Thanks for that advice man!
Add Comment