aboutsummaryrefslogtreecommitdiff
path: root/libc/stdlib/labs.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdlib/labs.c')
-rw-r--r--libc/stdlib/labs.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libc/stdlib/labs.c b/libc/stdlib/labs.c
new file mode 100644
index 0000000..9b68bb2
--- /dev/null
+++ b/libc/stdlib/labs.c
@@ -0,0 +1,25 @@
+/******************************************************************************
+ * Copyright (c) 2017 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#include <stdlib.h>
+
+/**
+ * labs() - Computes the absolute value of long integer
+ * @n: long integer number
+ *
+ * Returns the absolute value of the long integer argument
+ */
+
+long int labs(long int n)
+{
+ return (n > 0) ? n : -n;
+}