File: msvc-compat.c

package info (click to toggle)
ngspice 26-1
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie-kfreebsd
  • size: 49,436 kB
  • sloc: ansic: 463,259; sh: 11,107; xml: 6,938; makefile: 3,574; yacc: 1,509; perl: 1,214; tcl: 1,025; pascal: 702; lex: 319
file content (47 lines) | stat: -rw-r--r-- 791 bytes parent folder | download | duplicates (3)
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
#include <math.h>

/*
 * some rather simple minded replacements
 *  for functions missing in most msvc incarnations
 */

double
x_trunc(double x)
{
    return (x < 0) ? ceil(x) : floor(x);
}


double
x_nearbyint(double x)
{
    /* thats grossly incorrect, anyway, don't worry, be crappy ... */
    return floor(x + 0.5);
}


double
x_asinh(double x)
{
    return (x > 0) ? log(x + sqrt(x * x + 1.0)) : -log(-x + sqrt(x * x + 1.0));
}

double
x_acosh(double x)
{
    /* domain check (HUGE_VAL like gnu libc) */
    if (x < 1.0)
        return HUGE_VAL;
    else
        return log(x + sqrt(x * x - 1.0));
}

double
x_atanh(double x)
{
    /* domain check (HUGE_VAL like gnu libc) */
    if (fabs(x) >= 1.0)
        return HUGE_VAL;
    else
        return log((1.0 + x) / (1.0 - x)) / 2.0;
}