os/ossrv/genericopenlibs/cstdlib/LMATH/S_FABS.C
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /* S_FABS.C
     2  * 
     3  * Portions Copyright (c) 1993-2005 Nokia Corporation and/or its subsidiary(-ies).
     4  * All rights reserved.
     5  */
     6 
     7 
     8 /* @(#)s_fabs.c 5.1 93/09/24 */
     9 /*
    10  * ====================================================
    11  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
    12  *
    13  * Developed at SunPro, a Sun Microsystems, Inc. business.
    14  * Permission to use, copy, modify, and distribute this
    15  * software is freely granted, provided that this notice 
    16  * is preserved.
    17  * ====================================================
    18  */
    19 
    20 /*
    21 FUNCTION
    22        <<fabs>>, <<fabsf>>---absolute value (magnitude)
    23 INDEX
    24 	fabs
    25 INDEX
    26 	fabsf
    27 
    28 ANSI_SYNOPSIS
    29 	#include <math.h>
    30        double fabs(double <[x]>);
    31        float fabsf(float <[x]>);
    32 
    33 TRAD_SYNOPSIS
    34 	#include <math.h>
    35        double fabs(<[x]>) 
    36        double <[x]>;
    37 
    38        float fabsf(<[x]>)
    39        float <[x]>;
    40 
    41 DESCRIPTION
    42 <<fabs>> and <<fabsf>> calculate 
    43 @tex
    44 $|x|$, 
    45 @end tex
    46 the absolute value (magnitude) of the argument <[x]>, by direct
    47 manipulation of the bit representation of <[x]>.
    48 
    49 RETURNS
    50 The calculated value is returned.  No errors are detected.
    51 
    52 PORTABILITY
    53 <<fabs>> is ANSI.
    54 <<fabsf>> is an extension.
    55 
    56 */
    57 
    58 /*
    59  * fabs(x) returns the absolute value of x.
    60  */
    61 
    62 #include "FDLIBM.H"
    63 
    64 /**
    65 Return absolute value of floating-point.
    66 Returns the absoulte value of parameter x. /x/ 
    67 @return Absoulte value of x.
    68 @param x Floating point value.
    69 */
    70 EXPORT_C double fabs(double x) __SOFTFP
    71 {
    72 	__uint32_t high;
    73 	GET_HIGH_WORD(high,x);
    74 	SET_HIGH_WORD(x,high&0x7fffffff);
    75         return x;
    76 }