mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* configure.in: Check nextafter() availability.
* include/ruby/missing.h (nextafter): New optional declaration. * missing/nextafter.c: New file. * numeric.c: Float#next_float and Float#prev_float implemented. [ruby-core:62562] [Feature #9834] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ddd155842f
commit
63fee73500
12 changed files with 361 additions and 0 deletions
36
ext/-test-/float/nextafter.c
Normal file
36
ext/-test-/float/nextafter.c
Normal file
|
|
@ -0,0 +1,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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue