Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3362 Serge 1
 
2
/*
3
 * ====================================================
4
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
7
 * Permission to use, copy, modify, and distribute this
8
 * software is freely granted, provided that this notice
9
 * is preserved.
10
 * ====================================================
11
 */
12
13
 
14
FUNCTION
15
       <>, <>---absolute value (magnitude)
16
INDEX
17
	fabs
18
INDEX
19
	fabsf
20
21
 
22
	#include 
23
       double fabs(double <[x]>);
24
       float fabsf(float <[x]>);
25
26
 
27
	#include 
28
       double fabs(<[x]>)
29
       double <[x]>;
30
31
 
32
       float <[x]>;
33
34
 
35
<> and <> calculate
36
@tex
37
$|x|$,
38
@end tex
39
the absolute value (magnitude) of the argument <[x]>, by direct
40
manipulation of the bit representation of <[x]>.
41
42
 
43
The calculated value is returned.  No errors are detected.
44
45
 
46
<> is ANSI.
47
<> is an extension.
48
49
 
50
51
 
52
 * fabs(x) returns the absolute value of x.
53
 */
54
55
 
56
57
 
58
59
 
60
	double fabs(double x)
61
#else
62
	double fabs(x)
63
	double x;
64
#endif
65
{
66
	__uint32_t high;
67
	GET_HIGH_WORD(high,x);
68
	SET_HIGH_WORD(x,high&0x7fffffff);
69
        return x;
70
}
71
72
 
73