Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions | Variables
rational.c File Reference
`#include "ruby.h"`
`#include "internal.h"`
`#include <math.h>`
`#include <float.h>`
`#include <assert.h>`
`#include <ctype.h>`
Include dependency graph for rational.c:

Go to the source code of this file.

## Macros
#define | NDEBUG
#define | ZERO INT2FIX(0)
#define | ONE INT2FIX(1)
#define | TWO INT2FIX(2)
#define | f_boolcast(x) ((x) ? Qtrue : Qfalse)
#define | binop(n, op)
#define | fun1(n)
#define | fun2(n)
#define | f_expt10(x) f_expt(INT2FIX(10), x)
#define | f_positive_p(x) (!f_negative_p(x))
#define | f_nonzero_p(x) (!f_zero_p(x))
#define | k_exact_p(x) (!k_float_p(x))
#define | k_inexact_p(x) k_float_p(x)
#define | k_exact_zero_p(x) (k_exact_p(x) && f_zero_p(x))
#define | k_exact_one_p(x) (k_exact_p(x) && f_one_p(x))
#define | get_dat1(x)
#define | get_dat2(x, y)
#define | rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by 0")
#define | id_ceil rb_intern("ceil")
#define | f_ceil(x) rb_funcall((x), id_ceil, 0)
#define | id_quo rb_intern("quo")
#define | f_quo(x, y) rb_funcall((x), id_quo, 1, (y))
#define | f_reciprocal(x) f_quo(ONE, (x))
#define | id_numerator rb_intern("numerator")
#define | f_numerator(x) rb_funcall((x), id_numerator, 0)
#define | id_denominator rb_intern("denominator")
#define | f_denominator(x) rb_funcall((x), id_denominator, 0)
#define | id_to_r rb_intern("to_r")
#define | f_to_r(x) rb_funcall((x), id_to_r, 0)
#define | id_lshift rb_intern("<<")
#define | f_lshift(x, n) rb_funcall((x), id_lshift, 1, (n))
#define | rb_intern(str) rb_intern_const(str)

## Functions
static VALUE | f_add (VALUE x, VALUE y)
static VALUE | f_cmp (VALUE x, VALUE y)
static VALUE | f_div (VALUE x, VALUE y)
static VALUE | f_gt_p (VALUE x, VALUE y)
static VALUE | f_lt_p (VALUE x, VALUE y)
static VALUE | f_mul (VALUE x, VALUE y)
static VALUE | f_sub (VALUE x, VALUE y)
static VALUE | f_to_i (VALUE x)
static VALUE | f_to_f (VALUE x)
static VALUE | f_eqeq_p (VALUE x, VALUE y)
static VALUE | f_negative_p (VALUE x)
static VALUE | f_zero_p (VALUE x)
static VALUE | f_one_p (VALUE x)
static VALUE | f_minus_one_p (VALUE x)
static VALUE | f_kind_of_p (VALUE x, VALUE c)
static VALUE | k_numeric_p (VALUE x)
static VALUE | k_integer_p (VALUE x)
static VALUE | k_float_p (VALUE x)
static VALUE | k_rational_p (VALUE x)
static long | i_gcd (long x, long y)
static VALUE | f_gcd (VALUE x, VALUE y)
static VALUE | f_lcm (VALUE x, VALUE y)
static VALUE | nurat_s_new_internal (VALUE klass, VALUE num, VALUE den)
static VALUE | nurat_s_alloc (VALUE klass)
static VALUE | f_rational_new_bang1 (VALUE klass, VALUE x)
static VALUE | f_rational_new_bang2 (VALUE klass, VALUE x, VALUE y)
static void | nurat_int_check (VALUE num)
static VALUE | nurat_int_value (VALUE num)
static VALUE | nurat_s_canonicalize_internal (VALUE klass, VALUE num, VALUE den)
static VALUE | nurat_s_canonicalize_internal_no_reduce (VALUE klass, VALUE num, VALUE den)
static VALUE | nurat_s_new (int argc, VALUE *argv, VALUE klass)
static VALUE | f_rational_new1 (VALUE klass, VALUE x)
static VALUE | f_rational_new2 (VALUE klass, VALUE x, VALUE y)
static VALUE | f_rational_new_no_reduce1 (VALUE klass, VALUE x)
static VALUE | f_rational_new_no_reduce2 (VALUE klass, VALUE x, VALUE y)
static VALUE | nurat_f_rational (int argc, VALUE *argv, VALUE klass)
static VALUE | nurat_numerator (VALUE self)
static VALUE | nurat_denominator (VALUE self)
static VALUE | f_imul (long a, long b)
static VALUE | f_addsub (VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
static VALUE | nurat_add (VALUE self, VALUE other)
static VALUE | nurat_sub (VALUE self, VALUE other)
static VALUE | f_muldiv (VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
static VALUE | nurat_mul (VALUE self, VALUE other)
static VALUE | nurat_div (VALUE self, VALUE other)
static VALUE | nurat_fdiv (VALUE self, VALUE other)
static VALUE | f_odd_p (VALUE integer)
static VALUE | nurat_expt (VALUE self, VALUE other)
static VALUE | nurat_cmp (VALUE self, VALUE other)
static VALUE | nurat_eqeq_p (VALUE self, VALUE other)
static VALUE | nurat_coerce (VALUE self, VALUE other)
static VALUE | nurat_floor (VALUE self)
static VALUE | nurat_ceil (VALUE self)
static VALUE | nurat_truncate (VALUE self)
static VALUE | nurat_round (VALUE self)
static VALUE | f_round_common (int argc, VALUE *argv, VALUE self, VALUE(*func)(VALUE))
static VALUE | nurat_floor_n (int argc, VALUE *argv, VALUE self)
static VALUE | nurat_ceil_n (int argc, VALUE *argv, VALUE self)
static VALUE | nurat_truncate_n (int argc, VALUE *argv, VALUE self)
static VALUE | nurat_round_n (int argc, VALUE *argv, VALUE self)
static VALUE | nurat_to_f (VALUE self)
static VALUE | nurat_to_r (VALUE self)
static void | nurat_rationalize_internal (VALUE a, VALUE b, VALUE *p, VALUE *q)
static VALUE | nurat_rationalize (int argc, VALUE *argv, VALUE self)
static VALUE | nurat_hash (VALUE self)
static VALUE | f_format (VALUE self, VALUE(*func)(VALUE))
static VALUE | nurat_to_s (VALUE self)
static VALUE | nurat_inspect (VALUE self)
static VALUE | nurat_dumper (VALUE self)
static VALUE | nurat_loader (VALUE self, VALUE a)
static VALUE | nurat_marshal_dump (VALUE self)
static VALUE | nurat_marshal_load (VALUE self, VALUE a)
VALUE | rb_rational_reciprocal (VALUE x)
VALUE | rb_gcd (VALUE self, VALUE other)
VALUE | rb_lcm (VALUE self, VALUE other)
VALUE | rb_gcdlcm (VALUE self, VALUE other)
VALUE | rb_rational_raw (VALUE x, VALUE y)
VALUE | rb_rational_new (VALUE x, VALUE y)
static VALUE | nurat_s_convert (int argc, VALUE *argv, VALUE klass)
VALUE | rb_Rational (VALUE x, VALUE y)
static VALUE | numeric_numerator (VALUE self)
static VALUE | numeric_denominator (VALUE self)
static VALUE | integer_numerator (VALUE self)
static VALUE | integer_denominator (VALUE self)
static VALUE | float_numerator (VALUE self)
static VALUE | float_denominator (VALUE self)
static VALUE | nilclass_to_r (VALUE self)
static VALUE | nilclass_rationalize (int argc, VALUE *argv, VALUE self)
static VALUE | integer_to_r (VALUE self)
static VALUE | integer_rationalize (int argc, VALUE *argv, VALUE self)
static void | float_decode_internal (VALUE self, VALUE *rf, VALUE *rn)
static VALUE | float_to_r (VALUE self)
static VALUE | float_rationalize (int argc, VALUE *argv, VALUE self)
static int | issign (int c)
static int | read_sign (const char **s)
static int | isdecimal (int c)
static int | read_digits (const char **s, int strict, VALUE *num, int *count)
static int | islettere (int c)
static int | read_num (const char **s, int numsign, int strict, VALUE *num)
static int | read_den (const char **s, int strict, VALUE *num)
static int | read_rat_nos (const char **s, int sign, int strict, VALUE *num)
static int | read_rat (const char **s, int strict, VALUE *num)
static void | skip_ws (const char **s)
static int | parse_rat (const char *s, int strict, VALUE *num)
static VALUE | string_to_r_strict (VALUE self)
static VALUE | string_to_r (VALUE self)
VALUE | rb_cstr_to_rat (const char *s, int strict)
void | Init_Rational (void)

## Variables
VALUE | rb_cRational
static ID | id_abs
static ID | id_cmp
static ID | id_convert
static ID | id_eqeq_p
static ID | id_expt
static ID | id_fdiv
static ID | id_floor
static ID | id_idiv
static ID | id_inspect
static ID | id_integer_p
static ID | id_negate
static ID | id_to_f
static ID | id_to_i
static ID | id_to_s
static ID | id_truncate
static ID | id_i_num
static ID | id_i_den

## Macro Definition Documentation

#define binop | ( |  | n,
|  |  | op
| ) |  |

Value:
inline static VALUE \
f_##n(VALUE x, VALUE y)\
{\
return rb_funcall(x, (op), 1, y);\
}
n
ssize_t n
Definition: bigdecimal.c:5655
return
return
Definition: bigdecimal.c:5800
rb_funcall
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:774
VALUE
unsigned long VALUE
Definition: ripper.y:104

Definition at line 32 of file rational.c.

#define f_boolcast | ( |  | x | ) | ((x) ? Qtrue : Qfalse)

Definition at line 30 of file rational.c.

Referenced by f_eqeq_p(), f_gt_p(), f_lt_p(), f_minus_one_p(), f_negative_p(), f_one_p(), f_zero_p(), and nurat_eqeq_p().

#define f_ceil | ( |  | x | ) | rb_funcall((x), id_ceil, 0)

Definition at line 1427 of file rational.c.

Referenced by nurat_rationalize_internal().

#define f_denominator | ( |  | x | ) | rb_funcall((x), id_denominator, 0)

Definition at line 1765 of file rational.c.

Referenced by nucomp_denominator(), nucomp_expt(), nucomp_numerator(), and numeric_denominator().

#define f_expt10 | ( |  | x | ) | f_expt(INT2FIX(10), x)

Definition at line 171 of file rational.c.

Referenced by f_round_common(), and read_num().

#define f_lshift | ( |  | x,
|  |  | n
| ) |  | rb_funcall((x), id_lshift, 1, (n))

Definition at line 1935 of file rational.c.

Referenced by float_rationalize(), and float_to_r().

#define f_nonzero_p | ( |  | x | ) | (!f_zero_p(x))

Definition at line 201 of file rational.c.

Referenced by f_rational_new_bang2().

#define f_numerator | ( |  | x | ) | rb_funcall((x), id_numerator, 0)

Definition at line 1762 of file rational.c.

Referenced by nucomp_expt(), nucomp_numerator(), and numeric_numerator().

#define f_positive_p | ( |  | x | ) | (!f_negative_p(x))

Definition at line 181 of file rational.c.

Referenced by f_rational_new_bang2(), and float_rationalize().

#define f_quo | ( |  | x,
|  |  | y
| ) |  | rb_funcall((x), id_quo, 1, (y))

Definition at line 1430 of file rational.c.

#define f_reciprocal | ( |  | x | ) | f_quo(ONE, (x))

Definition at line 1432 of file rational.c.

Referenced by nurat_rationalize_internal().

#define f_to_r | ( |  | x | ) | rb_funcall((x), id_to_r, 0)

Definition at line 1768 of file rational.c.

Referenced by float_rationalize(), float_to_r(), numeric_denominator(), numeric_numerator(), and nurat_s_convert().

#define fun1 | ( |  | n | ) |

Value:
inline static VALUE \
f_##n(VALUE x)\
{\
return rb_funcall(x, id_##n, 0);\
}
n
ssize_t n
Definition: bigdecimal.c:5655
return
return
Definition: bigdecimal.c:5800
rb_funcall
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:774
VALUE
unsigned long VALUE
Definition: ripper.y:104

Definition at line 39 of file rational.c.

#define fun2 | ( |  | n | ) |

Value:
inline static VALUE \
f_##n(VALUE x, VALUE y)\
{\
return rb_funcall(x, id_##n, 1, y);\
}
n
ssize_t n
Definition: bigdecimal.c:5655
return
return
Definition: bigdecimal.c:5800
rb_funcall
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:774
VALUE
unsigned long VALUE
Definition: ripper.y:104

Definition at line 46 of file rational.c.

#define get_dat1 | ( |  | x | ) |

Value:
struct RRational *dat;\
dat = ((struct RRational *)(x))
RRational
Definition: ripper.y:939

Definition at line 359 of file rational.c.

Referenced by f_format(), nurat_add(), nurat_ceil(), nurat_cmp(), nurat_denominator(), nurat_div(), nurat_eqeq_p(), nurat_expt(), nurat_floor(), nurat_hash(), nurat_loader(), nurat_marshal_dump(), nurat_mul(), nurat_numerator(), nurat_round(), nurat_sub(), nurat_to_f(), nurat_truncate(), and rb_rational_reciprocal().

#define get_dat2 | ( |  | x,
|  |  | y
| ) |  |

Value:
struct RRational *adat, *bdat;\
adat = ((struct RRational *)(x));\
bdat = ((struct RRational *)(y))
RRational
Definition: ripper.y:939

Definition at line 363 of file rational.c.

Referenced by nurat_add(), nurat_cmp(), nurat_div(), nurat_eqeq_p(), nurat_mul(), and nurat_sub().

#define id_ceil rb_intern("ceil")

Definition at line 1426 of file rational.c.

#define id_denominator rb_intern("denominator")

Definition at line 1764 of file rational.c.

#define id_lshift rb_intern("<<")

Definition at line 1934 of file rational.c.

#define id_numerator rb_intern("numerator")

Definition at line 1761 of file rational.c.

#define id_quo rb_intern("quo")

Definition at line 1429 of file rational.c.

#define id_to_r rb_intern("to_r")

Definition at line 1767 of file rational.c.

#define k_exact_one_p | ( |  | x | ) | (k_exact_p(x) && f_one_p(x))

Definition at line 277 of file rational.c.

Referenced by nurat_s_convert().

#define k_exact_p | ( |  | x | ) | (!k_float_p(x))

Definition at line 273 of file rational.c.

Referenced by nurat_expt().

#define k_exact_zero_p | ( |  | x | ) | (k_exact_p(x) && f_zero_p(x))

Definition at line 276 of file rational.c.

Referenced by nurat_coerce(), nurat_expt(), and nurat_s_convert().

#define k_inexact_p | ( |  | x | ) | k_float_p(x)

Definition at line 274 of file rational.c.

#define NDEBUG

Definition at line 17 of file rational.c.

#define ONE INT2FIX(1)

Definition at line 21 of file rational.c.

Referenced by f_one_p(), f_rational_new1(), f_rational_new_bang1(), f_rational_new_no_reduce1(), f_round_common(), float_rationalize(), float_to_r(), nurat_add(), nurat_div(), nurat_expt(), nurat_mul(), nurat_rationalize_internal(), nurat_s_alloc(), nurat_s_new(), nurat_sub(), and read_num().

#define rb_intern | ( |  | str | ) | rb_intern_const(str)

#define rb_raise_zerodiv | ( |  | ) | rb_raise(rb_eZeroDivError, "divided by 0")

Definition at line 385 of file rational.c.

Referenced by nurat_div(), nurat_expt(), nurat_marshal_load(), nurat_s_canonicalize_internal(), and nurat_s_canonicalize_internal_no_reduce().

#define TWO INT2FIX(2)

Definition at line 22 of file rational.c.

Referenced by float_rationalize(), and nurat_round().

#define ZERO INT2FIX(0)

Definition at line 20 of file rational.c.

## Function Documentation

static VALUE f_add | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 54 of file rational.c.

References FIX2LONG, FIXNUM_P, and rb_funcall().

Referenced by f_addsub(), float_rationalize(), nurat_add(), nurat_rationalize(), nurat_rationalize_internal(), nurat_round(), and read_num().

static VALUE f_addsub | ( | VALUE | self,
|  | VALUE | anum,
|  | VALUE | aden,
|  | VALUE | bnum,
|  | VALUE | bden,
|  | int | k
| ) |  |
| inline static

Definition at line 670 of file rational.c.

References a, b, c, CLASS_OF, f_add(), f_gcd(), f_idiv, f_imul(), f_mul(), f_rational_new_no_reduce2(), f_sub(), FIX2LONG, FIXNUM_P, i_gcd(), and LONG2NUM.

Referenced by nurat_add(), and nurat_sub().

static VALUE f_cmp | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 64 of file rational.c.

References c, FIX2LONG, FIXNUM_P, id_cmp, INT2FIX, and rb_funcall().

Referenced by nurat_cmp(), nurat_expt(), nurat_s_canonicalize_internal(), and nurat_s_canonicalize_internal_no_reduce().

static VALUE f_div | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 78 of file rational.c.

References FIX2LONG, FIXNUM_P, and rb_funcall().

Referenced by f_lcm(), f_round_common(), nurat_fdiv(), nurat_s_convert(), read_num(), and read_rat_nos().

static VALUE f_eqeq_p | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 160 of file rational.c.

References f_boolcast, FIX2LONG, FIXNUM_P, id_eqeq_p, and rb_funcall().

Referenced by float_rationalize(), nurat_eqeq_p(), and nurat_rationalize().

static VALUE f_format | ( | VALUE | self,
|  | VALUE(*)(VALUE) | func
| ) |  |
| static

Definition at line 1576 of file rational.c.

References func, get_dat1, rb_str_cat2(), rb_str_concat(), and s.

Referenced by nurat_inspect(), and nurat_to_s().

static VALUE f_gcd | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 305 of file rational.c.

References f_mod, f_negate, f_negative_p(), f_zero_p(), FIX2LONG, FIXNUM_P, i_gcd(), and LONG2NUM.

Referenced by f_addsub(), f_lcm(), f_muldiv(), nurat_s_canonicalize_internal(), rb_gcd(), and rb_gcdlcm().

static VALUE f_gt_p | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 86 of file rational.c.

References f_boolcast, FIX2LONG, FIXNUM_P, and rb_funcall().

static VALUE f_imul | ( | long | a,
|  | long | b
| ) |  |
| inline static

Definition at line 639 of file rational.c.

References LONG2NUM, MUL_OVERFLOW_LONG_P, r, rb_big_mul(), rb_int2big(), and ZERO.

Referenced by f_addsub(), f_muldiv(), and nurat_cmp().

static VALUE f_kind_of_p | ( | VALUE | x,
|  | VALUE | c
| ) |  |
| inline static

Definition at line 244 of file rational.c.

References rb_obj_is_kind_of().

Referenced by k_float_p(), k_integer_p(), k_numeric_p(), and k_rational_p().

static VALUE f_lcm | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 352 of file rational.c.

References f_abs, f_div(), f_gcd(), f_mul(), f_zero_p(), and ZERO.

Referenced by rb_gcdlcm(), and rb_lcm().

static VALUE f_lt_p | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 94 of file rational.c.

References f_boolcast, FIX2LONG, FIXNUM_P, and rb_funcall().

Referenced by f_round_common(), and nurat_rationalize_internal().

static VALUE f_minus_one_p | ( | VALUE | x | ) |
| inline static

Definition at line 224 of file rational.c.

References f_boolcast, FIX2LONG, FIXNUM_P, id_eqeq_p, INT2FIX, Qfalse, rb_funcall(), RRATIONAL, T_BIGNUM, T_FIXNUM, T_RATIONAL, and TYPE.

Referenced by nurat_expt().

static VALUE f_mul | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 104 of file rational.c.

References FIX2LONG, FIXNUM_P, ix, rb_funcall(), RB_TYPE_P, T_BIGNUM, and ZERO.

Referenced by f_addsub(), f_lcm(), f_muldiv(), f_round_common(), float_rationalize(), float_to_r(), nurat_cmp(), nurat_div(), nurat_mul(), nurat_rationalize_internal(), nurat_round(), and read_num().

static VALUE f_muldiv | ( | VALUE | self,
|  | VALUE | anum,
|  | VALUE | aden,
|  | VALUE | bnum,
|  | VALUE | bden,
|  | int | k
| ) |  |
| inline static

Definition at line 799 of file rational.c.

References CLASS_OF, f_gcd(), f_idiv, f_imul(), f_mul(), f_negate, f_negative_p(), f_rational_new_no_reduce2(), FIX2LONG, FIXNUM_P, i_gcd(), and t.

Referenced by nurat_div(), and nurat_mul().

static VALUE f_negative_p | ( | VALUE | x | ) |
| inline static

Definition at line 174 of file rational.c.

References f_boolcast, FIX2LONG, FIXNUM_P, rb_funcall(), and ZERO.

Referenced by f_gcd(), f_muldiv(), float_rationalize(), nurat_rationalize(), nurat_round(), and nurat_truncate().

static VALUE f_odd_p | ( | VALUE | integer | ) |
| inline static

Definition at line 955 of file rational.c.

References INT2FIX, Qfalse, Qtrue, and rb_funcall().

Referenced by nurat_expt().

static VALUE f_one_p | ( | VALUE | x | ) |
| inline static

Definition at line 204 of file rational.c.

References f_boolcast, FIX2LONG, FIXNUM_P, id_eqeq_p, ONE, Qfalse, rb_funcall(), RRATIONAL, T_BIGNUM, T_FIXNUM, T_RATIONAL, and TYPE.

Referenced by nurat_div(), nurat_expt(), nurat_s_canonicalize_internal(), and nurat_s_canonicalize_internal_no_reduce().

static VALUE f_rational_new1 | ( | VALUE | klass,
|  | VALUE | x
| ) |  |
| inline static

Definition at line 537 of file rational.c.

References assert, k_rational_p(), nurat_s_canonicalize_internal(), and ONE.

static VALUE f_rational_new2 | ( | VALUE | klass,
|  | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 544 of file rational.c.

References assert, k_rational_p(), and nurat_s_canonicalize_internal().

Referenced by nurat_expt(), and nurat_rationalize().

static VALUE f_rational_new_bang1 | ( | VALUE | klass,
|  | VALUE | x
| ) |  |
| inline static

Definition at line 422 of file rational.c.

References nurat_s_new_internal(), and ONE.

Referenced by f_round_common(), nurat_cmp(), nurat_coerce(), and nurat_expt().

static VALUE f_rational_new_bang2 | ( | VALUE | klass,
|  | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 428 of file rational.c.

References assert, f_nonzero_p, f_positive_p, and nurat_s_new_internal().

static VALUE f_rational_new_no_reduce1 | ( | VALUE | klass,
|  | VALUE | x
| ) |  |
| inline static

Definition at line 552 of file rational.c.

References assert, k_rational_p(), nurat_s_canonicalize_internal_no_reduce(), and ONE.

static VALUE f_rational_new_no_reduce2 | ( | VALUE | klass,
|  | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 559 of file rational.c.

References assert, k_rational_p(), and nurat_s_canonicalize_internal_no_reduce().

Referenced by f_addsub(), f_muldiv(), nurat_div(), and rb_rational_reciprocal().

static VALUE f_round_common | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self,
|  | VALUE(*)(VALUE) | func
| ) |  |
| static

Definition at line 1261 of file rational.c.

References b, CLASS_OF, f_div(), f_expt10, f_lt_p(), f_mul(), f_rational_new_bang1(), f_to_i(), func, k_float_p(), k_integer_p(), k_rational_p(), n, ONE, rb_eTypeError, rb_raise(), rb_scan_args(), s, and ZERO.

Referenced by nurat_ceil_n(), nurat_floor_n(), nurat_round_n(), and nurat_truncate_n().

static VALUE f_sub | ( | VALUE | x,
|  | VALUE | y
| ) |  |
| inline static

Definition at line 128 of file rational.c.

References FIX2LONG, FIXNUM_P, and rb_funcall().

Referenced by f_addsub(), float_rationalize(), nurat_cmp(), nurat_rationalize(), nurat_rationalize_internal(), and nurat_sub().

static VALUE f_to_f | ( | VALUE | x | ) |
| inline static

Definition at line 149 of file rational.c.

References DBL2NUM, id_to_f, rb_funcall(), rb_str_to_dbl(), RB_TYPE_P, and T_STRING.

Referenced by nurat_add(), nurat_cmp(), nurat_coerce(), nurat_div(), nurat_eqeq_p(), nurat_expt(), nurat_fdiv(), nurat_mul(), and nurat_sub().

static VALUE f_to_i | ( | VALUE | x | ) |
| inline static

Definition at line 142 of file rational.c.

References id_to_i, rb_funcall(), rb_str_to_inum(), RB_TYPE_P, and T_STRING.

Referenced by f_round_common(), and nurat_int_value().

static VALUE f_zero_p | ( | VALUE | x | ) |
| inline static

Definition at line 184 of file rational.c.

References f_boolcast, FIX2LONG, FIXNUM_P, id_eqeq_p, Qfalse, rb_funcall(), RRATIONAL, T_BIGNUM, T_FIXNUM, T_RATIONAL, TYPE, and ZERO.

Referenced by f_gcd(), f_lcm(), float_rationalize(), nurat_div(), nurat_eqeq_p(), nurat_expt(), nurat_fdiv(), and nurat_marshal_load().

static void float_decode_internal | ( | VALUE | self,
|  | VALUE * | rf,
|  | VALUE * | rn
| ) |  |
| static

Definition at line 1911 of file rational.c.

References DBL_MANT_DIG, f, INT2FIX, n, rb_dbl2big(), and RFLOAT_VALUE.

Referenced by float_rationalize(), and float_to_r().

static VALUE float_denominator | ( | VALUE | self | ) |
| static

Definition at line 1847 of file rational.c.

References d, INT2FIX, isinf(), isnan, rb_call_super(), and RFLOAT_VALUE.

Referenced by Init_Rational().

static VALUE float_numerator | ( | VALUE | self | ) |
| static

Definition at line 1829 of file rational.c.

References d, isinf(), isnan, rb_call_super(), and RFLOAT_VALUE.

Referenced by Init_Rational().

static VALUE float_rationalize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1990 of file rational.c.

References a, b, e, f, f_abs, f_add(), f_eqeq_p(), f_expt, f_lshift, f_mul(), f_negate, f_negative_p(), f_positive_p, f_sub(), f_to_r, f_zero_p(), float_decode_internal(), FLT_RADIX, INT2FIX, n, nurat_rationalize_internal(), ONE, p, q, rb_rational_new1, rb_rational_new2, rb_scan_args(), and TWO.

Referenced by Init_Rational().

static VALUE float_to_r | ( | VALUE | self | ) |
| static

Definition at line 1954 of file rational.c.

References f, f_expt, f_lshift, f_mul(), f_to_r, FIX2LONG, float_decode_internal(), FLT_RADIX, INT2FIX, n, ONE, and rb_rational_new2.

Referenced by Init_Rational().

static long i_gcd | ( | long | x,
|  | long | y
| ) |  |
| inline static

Definition at line 284 of file rational.c.

References t.

Referenced by f_addsub(), f_gcd(), and f_muldiv().

void Init_Rational | ( | void |  | ) |

Definition at line 2435 of file rational.c.

References assert, CLASS_OF, float_denominator(), float_numerator(), float_rationalize(), float_to_r(), id_abs, id_cmp, id_convert, id_eqeq_p, id_expt, id_fdiv, id_floor, id_i_den, id_i_num, id_idiv, id_inspect, id_integer_p, id_negate, id_to_f, id_to_i, id_to_s, id_truncate, integer_denominator(), integer_numerator(), integer_rationalize(), integer_to_r(), nilclass_rationalize(), nilclass_to_r(), numeric_denominator(), numeric_numerator(), nurat_add(), nurat_ceil_n(), nurat_cmp(), nurat_coerce(), nurat_denominator(), nurat_div(), nurat_dumper(), nurat_eqeq_p(), nurat_expt(), nurat_f_rational(), nurat_fdiv(), nurat_floor_n(), nurat_hash(), nurat_inspect(), nurat_loader(), nurat_marshal_dump(), nurat_marshal_load(), nurat_mul(), nurat_numerator(), nurat_rationalize(), nurat_round_n(), nurat_s_alloc(), nurat_s_convert(), nurat_s_new(), nurat_sub(), nurat_to_f(), nurat_to_r(), nurat_to_s(), nurat_truncate(), nurat_truncate_n(), rb_cFloat, rb_cInteger, rb_cNilClass, rb_cNumeric, rb_cObject, rb_cRational, rb_cString, rb_define_alloc_func(), rb_define_class(), rb_define_class_under(), rb_define_global_function(), rb_define_method(), rb_define_private_method(), rb_gcd(), rb_gcdlcm(), rb_intern, rb_lcm(), rb_marshal_define_compat(), rb_undef_method(), and string_to_r().

static VALUE integer_denominator | ( | VALUE | self | ) |
| static

Definition at line 1813 of file rational.c.

References INT2FIX.

Referenced by Init_Rational().

static VALUE integer_numerator | ( | VALUE | self | ) |
| static

Definition at line 1801 of file rational.c.

Referenced by Init_Rational().

static VALUE integer_rationalize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1904 of file rational.c.

References integer_to_r(), NULL, and rb_scan_args().

Referenced by Init_Rational().

static VALUE integer_to_r | ( | VALUE | self | ) |
| static

Definition at line 1891 of file rational.c.

References rb_rational_new1.

Referenced by Init_Rational(), and integer_rationalize().

static int isdecimal | ( | int | c | ) |
| inline static

Definition at line 2062 of file rational.c.

Referenced by read_digits().

static int islettere | ( | int | c | ) |
| inline static

Definition at line 2110 of file rational.c.

Referenced by read_num().

static int issign | ( | int | c | ) |
| inline static

Definition at line 2044 of file rational.c.

Referenced by read_sign().

static VALUE k_float_p | ( | VALUE | x | ) |
| inline static

Definition at line 262 of file rational.c.

References f_kind_of_p(), and rb_cFloat.

Referenced by f_round_common().

static VALUE k_integer_p | ( | VALUE | x | ) |
| inline static

Definition at line 256 of file rational.c.

References f_kind_of_p(), and rb_cInteger.

Referenced by f_round_common(), nurat_expt(), nurat_int_value(), and nurat_s_convert().

static VALUE k_numeric_p | ( | VALUE | x | ) |
| inline static

Definition at line 250 of file rational.c.

References f_kind_of_p(), and rb_cNumeric.

Referenced by nurat_expt(), nurat_int_check(), and nurat_s_convert().

static VALUE k_rational_p | ( | VALUE | x | ) |
| inline static

Definition at line 268 of file rational.c.

References f_kind_of_p(), and rb_cRational.

Referenced by f_rational_new1(), f_rational_new2(), f_rational_new_no_reduce1(), f_rational_new_no_reduce2(), f_round_common(), and nurat_expt().

static VALUE nilclass_rationalize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1875 of file rational.c.

References nilclass_to_r(), NULL, and rb_scan_args().

Referenced by Init_Rational().

static VALUE nilclass_to_r | ( | VALUE | self | ) |
| static

Definition at line 1862 of file rational.c.

References INT2FIX, and rb_rational_new1.

Referenced by Init_Rational(), and nilclass_rationalize().

static VALUE numeric_denominator | ( | VALUE | self | ) |
| static

Definition at line 1789 of file rational.c.

References f_denominator, and f_to_r.

Referenced by Init_Rational().

static VALUE numeric_numerator | ( | VALUE | self | ) |
| static

Definition at line 1777 of file rational.c.

References f_numerator, and f_to_r.

Referenced by Init_Rational().

static VALUE nurat_add | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 731 of file rational.c.

References f_add(), f_addsub(), f_to_f(), get_dat1, get_dat2, ONE, rb_num_coerce_bin(), T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, and TYPE.

Referenced by Init_Rational().

static VALUE nurat_ceil | ( | VALUE | self | ) |
| static

Definition at line 1206 of file rational.c.

References f_idiv, f_negate, and get_dat1.

Referenced by nurat_ceil_n().

static VALUE nurat_ceil_n | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1339 of file rational.c.

References f_round_common(), and nurat_ceil().

Referenced by Init_Rational().

static VALUE nurat_cmp | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 1055 of file rational.c.

References CLASS_OF, f_cmp(), f_imul(), f_mul(), f_rational_new_bang1(), f_sub(), f_to_f(), FIX2LONG, FIXNUM_P, get_dat1, get_dat2, id_cmp, rb_num_coerce_cmp(), T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, TYPE, and ZERO.

Referenced by Init_Rational().

static VALUE nurat_coerce | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 1142 of file rational.c.

References CLASS_OF, f_rational_new_bang1(), f_to_f(), INT2FIX, k_exact_zero_p, Qnil, rb_assoc_new(), rb_Complex(), rb_eTypeError, rb_obj_classname(), rb_raise(), RCOMPLEX, T_BIGNUM, T_COMPLEX, T_FIXNUM, T_FLOAT, T_RATIONAL, and TYPE.

Referenced by Init_Rational().

static VALUE nurat_denominator | ( | VALUE | self | ) |
| static

Definition at line 628 of file rational.c.

References get_dat1.

Referenced by Init_Rational().

static VALUE nurat_div | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 891 of file rational.c.

References CLASS_OF, DBL2NUM, f_mul(), f_muldiv(), f_one_p(), f_rational_new_no_reduce2(), f_to_f(), f_zero_p(), get_dat1, get_dat2, INT2FIX, isinf(), isnan, NAN, ONE, rb_dbl2big(), rb_funcall(), rb_num_coerce_bin(), rb_raise_zerodiv, rb_rational_raw2, RFLOAT_VALUE, T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, and TYPE.

Referenced by Init_Rational().

static VALUE nurat_dumper | ( | VALUE | self | ) |
| static

Definition at line 1628 of file rational.c.

Referenced by Init_Rational().

static VALUE nurat_eqeq_p | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 1104 of file rational.c.

References f_boolcast, f_eqeq_p(), f_to_f(), f_zero_p(), FIX2LONG, FIXNUM_P, get_dat1, get_dat2, Qfalse, Qtrue, T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, and TYPE.

Referenced by Init_Rational().

static VALUE nurat_expt | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 978 of file rational.c.

References CLASS_OF, f_cmp(), f_expt, f_minus_one_p(), f_negate, f_odd_p(), f_one_p(), f_rational_new2(), f_rational_new_bang1(), f_to_f(), f_zero_p(), FIX2INT, get_dat1, id_expt, INT2FIX, k_exact_p, k_exact_zero_p, k_integer_p(), k_numeric_p(), k_rational_p(), ONE, rb_num_coerce_bin(), rb_raise_zerodiv, rb_warn(), T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, TYPE, and ZERO.

Referenced by Init_Rational().

static VALUE nurat_f_rational | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |
| static

Definition at line 592 of file rational.c.

References id_convert, rb_cRational, and rb_funcall2().

Referenced by Init_Rational().

static VALUE nurat_fdiv | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 947 of file rational.c.

References f_div(), f_to_f(), and f_zero_p().

Referenced by Init_Rational().

static VALUE nurat_floor | ( | VALUE | self | ) |
| static

Definition at line 1199 of file rational.c.

References f_idiv, and get_dat1.

Referenced by nurat_floor_n().

static VALUE nurat_floor_n | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1315 of file rational.c.

References f_round_common(), and nurat_floor().

Referenced by Init_Rational().

static VALUE nurat_hash | ( | VALUE | self | ) |
| static

Definition at line 1561 of file rational.c.

References get_dat1, LONG2FIX, n, NUM2LONG, rb_hash(), rb_memhash(), and v.

Referenced by Init_Rational().

static VALUE nurat_inspect | ( | VALUE | self | ) |
| static

Definition at line 1615 of file rational.c.

References f_format(), f_inspect, rb_str_cat2(), rb_str_concat(), rb_usascii_str_new2, and s.

Referenced by Init_Rational().

static void nurat_int_check | ( | VALUE | num | ) |
| inline static

Definition at line 450 of file rational.c.

References k_numeric_p(), rb_eTypeError, rb_raise(), T_BIGNUM, T_FIXNUM, and TYPE.

Referenced by nurat_int_value().

static VALUE nurat_int_value | ( | VALUE | num | ) |
| inline static

Definition at line 463 of file rational.c.

References f_to_i(), k_integer_p(), and nurat_int_check().

Referenced by nurat_s_new(), rb_gcd(), rb_gcdlcm(), and rb_lcm().

static VALUE nurat_loader | ( | VALUE | self,
|  | VALUE | a
| ) |  |
| static

Definition at line 1635 of file rational.c.

References get_dat1, id_i_den, id_i_num, and rb_ivar_get().

Referenced by Init_Rational().

static VALUE nurat_marshal_dump | ( | VALUE | self | ) |
| static

Definition at line 1647 of file rational.c.

References a, get_dat1, rb_assoc_new(), and rb_copy_generic_ivar().

Referenced by Init_Rational().

static VALUE nurat_marshal_load | ( | VALUE | self,
|  | VALUE | a
| ) |  |
| static

Definition at line 1659 of file rational.c.

References Check_Type, f_zero_p(), id_i_den, id_i_num, RARRAY_LEN, RARRAY_PTR(), rb_check_frozen, rb_check_trusted, rb_eArgError, rb_ivar_set(), rb_raise(), rb_raise_zerodiv, and T_ARRAY.

Referenced by Init_Rational().

static VALUE nurat_mul | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 850 of file rational.c.

References f_mul(), f_muldiv(), f_to_f(), get_dat1, get_dat2, ONE, rb_num_coerce_bin(), T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, and TYPE.

Referenced by Init_Rational().

static VALUE nurat_numerator | ( | VALUE | self | ) |
| static

Definition at line 609 of file rational.c.

References get_dat1.

Referenced by Init_Rational().

static VALUE nurat_rationalize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1537 of file rational.c.

References a, b, CLASS_OF, e, f_abs, f_add(), f_eqeq_p(), f_negate, f_negative_p(), f_rational_new2(), f_sub(), nurat_rationalize_internal(), p, q, and rb_scan_args().

Referenced by Init_Rational().

static void nurat_rationalize_internal | ( | VALUE | a,
|  | VALUE | b,
|  | VALUE * | p,
|  | VALUE * | q
| ) |  |
| static

Definition at line 1494 of file rational.c.

References c, f_add(), f_ceil, f_lt_p(), f_mul(), f_reciprocal, f_sub(), ONE, t, and ZERO.

Referenced by float_rationalize(), and nurat_rationalize().

static VALUE nurat_round | ( | VALUE | self | ) |
| static

Definition at line 1237 of file rational.c.

References f_add(), f_idiv, f_mul(), f_negate, f_negative_p(), get_dat1, neg, and TWO.

Referenced by nurat_round_n().

static VALUE nurat_round_n | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1388 of file rational.c.

References f_round_common(), and nurat_round().

Referenced by Init_Rational().

static VALUE nurat_s_alloc | ( | VALUE | klass | ) |
| static

Definition at line 380 of file rational.c.

References nurat_s_new_internal(), ONE, and ZERO.

Referenced by Init_Rational().

static VALUE nurat_s_canonicalize_internal | ( | VALUE | klass,
|  | VALUE | num,
|  | VALUE | den
| ) |  |
| inline static

Definition at line 472 of file rational.c.

References f_cmp(), f_gcd(), f_idiv, f_negate, f_one_p(), FIX2INT, nurat_s_new_internal(), rb_raise_zerodiv, and ZERO.

Referenced by f_rational_new1(), f_rational_new2(), nurat_s_new(), and rb_rational_new().

static VALUE nurat_s_canonicalize_internal_no_reduce | ( | VALUE | klass,
|  | VALUE | num,
|  | VALUE | den
| ) |  |
| inline static

Definition at line 498 of file rational.c.

References f_cmp(), f_negate, f_one_p(), FIX2INT, nurat_s_new_internal(), rb_raise_zerodiv, and ZERO.

Referenced by f_rational_new_no_reduce1(), and f_rational_new_no_reduce2().

static VALUE nurat_s_convert | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |
| static

Definition at line 2320 of file rational.c.

References f_div(), f_to_r, k_exact_one_p, k_exact_zero_p, k_integer_p(), k_numeric_p(), NIL_P(), nurat_s_new(), rb_backref_get(), rb_backref_set(), rb_convert_type(), rb_eTypeError, rb_match_busy(), rb_raise(), rb_scan_args(), RCOMPLEX, string_to_r_strict(), T_BIGNUM, T_COMPLEX, T_FIXNUM, T_FLOAT, T_RATIONAL, T_STRING, and TYPE.

Referenced by Init_Rational(), and rb_Rational().

static VALUE nurat_s_new | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |
| static

Definition at line 518 of file rational.c.

References nurat_int_value(), nurat_s_canonicalize_internal(), ONE, and rb_scan_args().

Referenced by Init_Rational(), and nurat_s_convert().

static VALUE nurat_s_new_internal | ( | VALUE | klass,
|  | VALUE | num,
|  | VALUE | den
| ) |  |
| inline static

Definition at line 369 of file rational.c.

References NEWOBJ_OF, obj, and T_RATIONAL.

Referenced by f_rational_new_bang1(), f_rational_new_bang2(), nurat_s_alloc(), nurat_s_canonicalize_internal(), nurat_s_canonicalize_internal_no_reduce(), and rb_rational_raw().

static VALUE nurat_sub | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 771 of file rational.c.

References f_addsub(), f_sub(), f_to_f(), get_dat1, get_dat2, ONE, rb_num_coerce_bin(), T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, and TYPE.

Referenced by Init_Rational().

static VALUE nurat_to_f | ( | VALUE | self | ) |
| static

Definition at line 1405 of file rational.c.

References get_dat1.

Referenced by Init_Rational().

static VALUE nurat_to_r | ( | VALUE | self | ) |
| static

Definition at line 1421 of file rational.c.

Referenced by Init_Rational().

static VALUE nurat_to_s | ( | VALUE | self | ) |
| static

Definition at line 1599 of file rational.c.

References f_format(), and f_to_s.

Referenced by Init_Rational().

static VALUE nurat_truncate | ( | VALUE | self | ) |
| static

Definition at line 1228 of file rational.c.

References f_idiv, f_negate, f_negative_p(), and get_dat1.

Referenced by Init_Rational(), and nurat_truncate_n().

static VALUE nurat_truncate_n | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1363 of file rational.c.

References f_round_common(), and nurat_truncate().

Referenced by Init_Rational().

static int parse_rat | ( | const char * | s,
|  | int | strict,
|  | VALUE * | num
| ) |  |
| static

Definition at line 2211 of file rational.c.

References read_rat(), and skip_ws().

Referenced by rb_cstr_to_rat(), string_to_r(), and string_to_r_strict().

VALUE rb_cstr_to_rat | ( | const char * | s,
|  | int | strict
| ) |  |

Definition at line 2308 of file rational.c.

References parse_rat(), rb_eFloatDomainError, rb_raise(), RB_TYPE_P, T_FLOAT, and void.

Referenced by str2num().

VALUE rb_gcd | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 1697 of file rational.c.

References f_gcd(), and nurat_int_value().

Referenced by Init_Rational().

VALUE rb_gcdlcm | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 1732 of file rational.c.

References f_gcd(), f_lcm(), nurat_int_value(), and rb_assoc_new().

Referenced by Init_Rational().

VALUE rb_lcm | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 1715 of file rational.c.

References f_lcm(), and nurat_int_value().

Referenced by Init_Rational(), and nucomp_denominator().

VALUE rb_Rational | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1753 of file rational.c.

References a, nurat_s_convert(), and rb_cRational.

Referenced by BigDecimal_to_r().

VALUE rb_rational_new | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1745 of file rational.c.

References nurat_s_canonicalize_internal(), and rb_cRational.

VALUE rb_rational_raw | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1739 of file rational.c.

References nurat_s_new_internal(), and rb_cRational.

VALUE rb_rational_reciprocal | ( | VALUE | x | ) |

Definition at line 1679 of file rational.c.

References CLASS_OF, f_rational_new_no_reduce2(), and get_dat1.

Referenced by fix_divide().

static int read_den | ( | const char ** | s,
|  | int | strict,
|  | VALUE * | num
| ) |  |
| inline static

Definition at line 2165 of file rational.c.

References NULL, and read_digits().

Referenced by read_rat_nos().

static int read_digits | ( | const char ** | s,
|  | int | strict,
|  | VALUE * | num,
|  | int * | count
| ) |  |
| static

Definition at line 2068 of file rational.c.

References ALLOCA_N, b, isdecimal(), rb_cstr_to_inum(), ret, s, strlen(), and ZERO.

Referenced by read_den(), and read_num().

static int read_num | ( | const char ** | s,
|  | int | numsign,
|  | int | strict,
|  | VALUE * | num
| ) |  |
| static

Definition at line 2116 of file rational.c.

References count, f_add(), f_div(), f_expt10, f_mul(), f_negate, INT2NUM, ip, islettere(), NIL_P(), NULL, ONE, Qnil, rb_rational_new2, read_digits(), read_sign(), and ZERO.

Referenced by read_rat_nos().

static int read_rat | ( | const char ** | s,
|  | int | strict,
|  | VALUE * | num
| ) |  |
| static

Definition at line 2192 of file rational.c.

References read_rat_nos(), and read_sign().

Referenced by parse_rat().

static int read_rat_nos | ( | const char ** | s,
|  | int | sign,
|  | int | strict,
|  | VALUE * | num
| ) |  |
| static

Definition at line 2174 of file rational.c.

References f_div(), FIX2LONG, FIXNUM_P, read_den(), and read_num().

Referenced by read_rat().

static int read_sign | ( | const char ** | s | ) |
| static

Definition at line 2050 of file rational.c.

References issign(), and s.

Referenced by read_num(), and read_rat().

static void skip_ws | ( | const char ** | s | ) |
| inline static

Definition at line 2204 of file rational.c.

Referenced by parse_rat().

static VALUE string_to_r | ( | VALUE | self | ) |
| static

Definition at line 2282 of file rational.c.

References parse_rat(), rb_eFloatDomainError, rb_must_asciicompat(), rb_raise(), rb_str_modify(), RB_TYPE_P, RSTRING_LEN, RSTRING_PTR, s, T_FLOAT, and void.

Referenced by Init_Rational().

static VALUE string_to_r_strict | ( | VALUE | self | ) |
| static

Definition at line 2226 of file rational.c.

References f_inspect, parse_rat(), rb_eArgError, rb_eFloatDomainError, rb_must_asciicompat(), rb_raise(), rb_str_modify(), RB_TYPE_P, RSTRING_LEN, RSTRING_PTR, s, StringValuePtr, and T_FLOAT.

Referenced by nurat_s_convert().

## Variable Documentation

ID id_abs
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational().

ID id_cmp
| static

Definition at line 26 of file rational.c.

Referenced by f_cmp(), Init_Rational(), and nurat_cmp().

ID id_convert
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational(), and nurat_f_rational().

ID id_eqeq_p
| static

Definition at line 26 of file rational.c.

Referenced by f_eqeq_p(), f_minus_one_p(), f_one_p(), f_zero_p(), and Init_Rational().

ID id_expt
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational(), and nurat_expt().

ID id_fdiv
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational().

ID id_floor
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational().

ID id_i_den
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational(), nurat_loader(), and nurat_marshal_load().

ID id_i_num
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational(), nurat_loader(), and nurat_marshal_load().

ID id_idiv
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational().

ID id_inspect
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational().

ID id_integer_p
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational().

ID id_negate
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational().

ID id_to_f
| static

Definition at line 26 of file rational.c.

Referenced by f_to_f(), and Init_Rational().

ID id_to_i
| static

Definition at line 26 of file rational.c.

Referenced by f_to_i(), and Init_Rational().

ID id_to_s
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational().

ID id_truncate
| static

Definition at line 26 of file rational.c.

Referenced by Init_Rational().

VALUE rb_cRational

Definition at line 24 of file rational.c.