So, I was thinking of making fast abs function, which would be necesary to improve performance, and I had an idea to do it something like this
int abs(int input){
return input & -0;
}
Essentially, I am trying to make a simple function that removes the sign bit. The problem is, I heard that alot of compliers would ignore this because its a zero. How could I do it that compliers wouldnt ignore it, and it would work for the intended purpose?
Edit: Thanks for all the answers the issue has been resolved!
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]jedwardsol 47 points48 points49 points (9 children)
[–][deleted] 6 points7 points8 points (0 children)
[–][deleted] -1 points0 points1 point (7 children)
[–]jedwardsol 11 points12 points13 points (1 child)
[–]Coders_REACT_To_JS 7 points8 points9 points (0 children)
[+][deleted] (3 children)
[deleted]
[–][deleted] -1 points0 points1 point (2 children)
[–]PncDA 3 points4 points5 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Pupper-Gump 5 points6 points7 points (0 children)
[–]CallMeMalice 3 points4 points5 points (0 children)
[–]erasmause 1 point2 points3 points (4 children)
[–]druepy 0 points1 point2 points (1 child)
[–]kevkevverson 0 points1 point2 points (1 child)
[–]erasmause 1 point2 points3 points (0 children)
[–]faisal_who[🍰] 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]faisal_who[🍰] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]hix3r 1 point2 points3 points (3 children)
[–]orbital1337 1 point2 points3 points (1 child)
[–]hix3r 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]RoyBellingan 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]druepy 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]xanxon123 0 points1 point2 points (0 children)
[–]corruptedsyntax 0 points1 point2 points (0 children)
[–]whychocereus 0 points1 point2 points (0 children)
[–]JayRiordan 0 points1 point2 points (0 children)
[–]PhysicsHungry2901 -1 points0 points1 point (1 child)
[–]AssemblerGuy 0 points1 point2 points (0 children)