1#ifndef INTERNAL_RATIONAL_H
2#define INTERNAL_RATIONAL_H
11#include "ruby/internal/config.h"
13#include "internal/numeric.h"
14#include "ruby_assert.h"
22#define RRATIONAL(obj) ((struct RRational *)(obj))
34VALUE rb_cstr_to_rat(
const char *,
int);
39VALUE rb_rational_floor(
VALUE self,
int ndigits);
41VALUE rb_flo_round_by_rational(
VALUE num,
int ndigits,
enum ruby_num_rounding_mode mode);
42VALUE rb_flo_ceil_by_rational(
VALUE num,
int ndigits);
43VALUE rb_flo_floor_by_rational(
VALUE num,
int ndigits);
47static inline void RATIONAL_SET_NUM(
VALUE r,
VALUE n);
48static inline void RATIONAL_SET_DEN(
VALUE r,
VALUE d);
50RUBY_SYMBOL_EXPORT_BEGIN
54#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
70 assert(INT_POSITIVE_P(d));
78 return FIXNUM_ZERO_P(x);
81 return FLOAT_ZERO_P(x);
84 const VALUE num = RRATIONAL(x)->num;
85 return FIXNUM_ZERO_P(num);
90#define f_nonzero_p(x) (!f_zero_p(x))
#define RB_INTEGER_TYPE_P
Old name of rb_integer_type_p.
#define INT2FIX
Old name of RB_INT2FIX.
#define T_RATIONAL
Old name of RUBY_T_RATIONAL.
VALUE rb_equal(VALUE lhs, VALUE rhs)
This function is an optimised version of calling #==.
#define RB_OBJ_WRITE(old, slot, young)
Declaration of a "back" pointer.
Ruby object's base components.
Internal header for Rational.
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_FLOAT_TYPE_P(VALUE obj)
Queries if the object is an instance of rb_cFloat.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.