File: e_hypotf.c

package info (click to toggle)
glibc 2.19-12
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 202,524 kB
  • ctags: 140,467
  • sloc: ansic: 969,237; asm: 241,206; sh: 10,046; makefile: 8,467; cpp: 3,595; perl: 2,077; pascal: 1,839; awk: 1,704; yacc: 317; sed: 73
file content (53 lines) | stat: -rw-r--r-- 1,213 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* e_hypotf.c -- float version of e_hypot.c.
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
 */

/*
 * ====================================================
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 *
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * is preserved.
 * ====================================================
 */

#include <math.h>
#include <math_private.h>

float
__ieee754_hypotf(float x, float y)
{
	double d_x, d_y;
	int32_t ha, hb;

	GET_FLOAT_WORD(ha,x);
	ha &= 0x7fffffff;
	GET_FLOAT_WORD(hb,y);
	hb &= 0x7fffffff;
	if (ha == 0x7f800000)
	  {
	    if (x == y)
	      return fabsf(y);
	    return fabsf(x);
	  }
	else if (hb == 0x7f800000)
	  {
	    if (x == y)
	      return fabsf(x);
	    return fabsf(y);
	  }
	else if (ha > 0x7f800000 || hb > 0x7f800000)
	  return fabsf(x) * fabsf(y);
	else if (ha == 0)
	  return fabsf(y);
	else if (hb == 0)
	  return fabsf(x);

	d_x = (double) x;
	d_y = (double) y;

	return (float) __ieee754_sqrt(d_x * d_x + d_y * d_y);
}
strong_alias (__ieee754_hypotf, __hypotf_finite)