fabs and abs, what’s the difference?

(Edit: For a full explaination visit this page http://wp.me/pDfud-X)

abs and fabs are used to get the absolute value of a primitve in C++. Usually int for abs and double or float for fabs.

For some sort of a bright reason I only used abs for all my primitives, including floating points primitves. The strange thing is that on the PC version it worked but on the Android version, which use the exact same code(so there won’t be duplicates of logic files), it didn’t work.

I don’t know how it worked on the PC so well, but on the Android I was getting back ints when doing abs on double, which caused a lot of calculation errors.

I think my PC version might have used an abs that returns a double and not int. Maybe related to some kind of library shenanigens. I will try to research it and make a more educated post in the future, so this post is mainly a note for myself and a warnning for anyone reckless enough to make the same mistake.

 

(Edit: For a full explaination visit this page http://wp.me/pDfud-X)