summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/-test-/float/nextafter.c
blob: 30fb71f520f856fd307d9ca8675ca40e799d074b (plain)
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
#include "ruby.h"

static VALUE
system_nextafter_m(VALUE klass, VALUE vx, VALUE vy)
{
    double x, y, z;

    x = NUM2DBL(vx);
    y = NUM2DBL(vy);
    z = nextafter(x, y);

    return DBL2NUM(z);
}

#define nextafter missing_nextafter
#include "../../../missing/nextafter.c"
#undef nextafter

static VALUE
missing_nextafter_m(VALUE klass, VALUE vx, VALUE vy)
{
    double x, y, z;

    x = NUM2DBL(vx);
    y = NUM2DBL(vy);
    z = missing_nextafter(x, y);

    return DBL2NUM(z);
}

void
Init_nextafter(VALUE klass)
{
    rb_define_singleton_method(klass, "system_nextafter", system_nextafter_m, 2);
    rb_define_singleton_method(klass, "missing_nextafter", missing_nextafter_m, 2);
}