//If it's negative, make it positive float abs(float value) { //If negative, multiply by -1 if(value < 0) { value *= -1; } return value; }
Algorithm for abs:
- If the value is less than 0, multiply it by negative 1.
- Return the value.
- End function.
//If it's negative, make it positive float abs(float value) { //If negative, multiply by -1 if(value < 0) { value *= -1; } return value; }
Algorithm for abs: