aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/mingw/math/hypotf.c
blob: 5cd1a279292b791bb1085afec92a7390fa4a9db7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * This file is part of the mingw-w64 runtime package.
 * No warranty is given; refer to the file DISCLAIMER within this package.
 */
#define _NEW_COMPLEX_FLOAT 1

#include "../complex/complex_internal.h"
#include <errno.h>
#include <math.h>

float hypotf (float x, float y)
{
  int x_class = fpclassify (x);
  int y_class = fpclassify (y);

  if (x_class == FP_INFINITE || y_class == FP_INFINITE)
    return __FLT_HUGE_VAL;
  else if (x_class == FP_NAN || y_class == FP_NAN)
    return __FLT_NAN;

  return (float) _hypot (x, y);
}