User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed



    #include <stdlib.h>
    long int labs(long int x);

computes the absolute value of a long integer

returns the absolute value of a number
the case of a negative number the sign is reversed, a positive number is returned unchanged.
labs is functionally equivalent to abs (), but uses the data type long int

C Sourcecode Example

#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 /* for printf */
#include <stdlib.h>
int main( void )
  long int i = -42;
  printf("labs from i = %li\n", labs(i));
  return 0;

output with abort:

  user@host:~/ ./labs 
  labs from i = 42

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdlib.h/labs.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz