Coverage Report

Created: 2026-10-28 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/r-source/src/nmath/fsign.c
Line
Count
Source
1
/*
2
 *  Mathlib : A C Library of Special Functions
3
 *  Copyright (C) 1998 Ross Ihaka
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, a copy is available at
17
 *  https://www.R-project.org/Licenses/
18
 *
19
 *  SYNOPSIS
20
 *
21
 *    #include <Rmath.h>
22
 *    double fsign(double x, double y);
23
 *
24
 *  DESCRIPTION
25
 *
26
 *    This function performs transfer of sign.  The result is:
27
 *
28
 *                        |x| * signum(y)
29
 */
30
31
#include "nmath.h"
32
33
double fsign(double x, double y)
34
0
{
35
0
#ifdef IEEE_754
36
0
    if (ISNAN(x) || ISNAN(y))
37
0
  return x + y;
38
0
#endif
39
0
    return ((y >= 0) ? fabs(x) : -fabs(x));
40
0
}