Absolute Value

The simplest absolute value function is simply negating any number that is negative.  This function uses only built in language features.

double OR2AbsoluteValue(const double & number) {
  if (number >= 0) {
    return number;
  }
  return -number;
}
Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 2 mths agoLast active
  • 4Views
  • 1 Following