URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 40 |
Rev 1765 |
/*
|
/*
|
FUNCTION
|
FUNCTION
|
<<labs>>---long integer absolute value
|
<<labs>>---long integer absolute value
|
|
|
INDEX
|
INDEX
|
labs
|
labs
|
|
|
ANSI_SYNOPSIS
|
ANSI_SYNOPSIS
|
#include <stdlib.h>
|
#include <stdlib.h>
|
long labs(long <[i]>);
|
long labs(long <[i]>);
|
|
|
TRAD_SYNOPSIS
|
TRAD_SYNOPSIS
|
#include <stdlib.h>
|
#include <stdlib.h>
|
long labs(<[i]>)
|
long labs(<[i]>)
|
long <[i]>;
|
long <[i]>;
|
|
|
DESCRIPTION
|
DESCRIPTION
|
<<labs>> returns
|
<<labs>> returns
|
@tex
|
@tex
|
$|x|$,
|
$|x|$,
|
@end tex
|
@end tex
|
the absolute value of <[i]> (also called the magnitude
|
the absolute value of <[i]> (also called the magnitude
|
of <[i]>). That is, if <[i]> is negative, the result is the opposite
|
of <[i]>). That is, if <[i]> is negative, the result is the opposite
|
of <[i]>, but if <[i]> is nonnegative the result is <[i]>.
|
of <[i]>, but if <[i]> is nonnegative the result is <[i]>.
|
|
|
The similar function <<abs>> uses and returns <<int>> rather than
|
The similar function <<abs>> uses and returns <<int>> rather than
|
<<long>> values.
|
<<long>> values.
|
|
|
RETURNS
|
RETURNS
|
The result is a nonnegative long integer.
|
The result is a nonnegative long integer.
|
|
|
PORTABILITY
|
PORTABILITY
|
<<labs>> is ANSI.
|
<<labs>> is ANSI.
|
|
|
No supporting OS subroutine calls are required.
|
No supporting OS subroutine calls are required.
|
*/
|
*/
|
|
|
#include <stdlib.h>
|
#include <stdlib.h>
|
|
|
long
|
long
|
_DEFUN (labs, (x),
|
_DEFUN (labs, (x),
|
long x)
|
long x)
|
{
|
{
|
if (x < 0)
|
if (x < 0)
|
{
|
{
|
x = -x;
|
x = -x;
|
}
|
}
|
return x;
|
return x;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.