1 Replies - 28240 Views - Last Post: 16 September 2009 - 10:45 AM Rate Topic: -----

#1 ComputerAnalysis  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 92
  • Joined: 29-June 09

abs vs fabs

Posted 16 September 2009 - 10:28 AM

Does anyone know what the difference is between abs and fabs and a reason why you would choose one over the other?
Is This A Good Question/Topic? 0
  • +

Replies To: abs vs fabs

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3101
  • View blog
  • Posts: 19,141
  • Joined: 14-September 07

Re: abs vs fabs

Posted 16 September 2009 - 10:45 AM

fabs() supports double/float whereas abs() supports int and long. Each have limited portability [perhaps functionality is a better word?] in C.


edit: More specificly, in C++, abs is overloaded so it can handle doubles as well, but in C, abs-> fabs-> double.

This post has been edited by KYA: 16 September 2009 - 10:46 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1