Ruby: internal/rational.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Functions
rational.h File Reference

Internal header for Rational. More...

`#include "ruby/internal/config.h"`
`#include "ruby/ruby.h"`
`#include "internal/gc.h"`
`#include "internal/numeric.h"`
`#include "ruby_assert.h"`

Go to the source code of this file.

## Data Structures
struct | RRational

## Macros
#define | RRATIONAL(obj) ((struct RRational *)(obj))

## Functions
VALUE | rb_rational_canonicalize (VALUE x)
VALUE | rb_rational_uminus (VALUE self)
VALUE | rb_rational_plus (VALUE self, VALUE other)
VALUE | rb_rational_minus (VALUE self, VALUE other)
VALUE | rb_rational_mul (VALUE self, VALUE other)
VALUE | rb_rational_div (VALUE self, VALUE other)
VALUE | rb_lcm (VALUE x, VALUE y)
VALUE | rb_rational_reciprocal (VALUE x)
VALUE | rb_cstr_to_rat (const char *, int)
VALUE | rb_rational_hash (VALUE self)
VALUE | rb_rational_abs (VALUE self)
VALUE | rb_rational_cmp (VALUE self, VALUE other)
VALUE | rb_rational_pow (VALUE self, VALUE other)
VALUE | rb_rational_floor (VALUE self, int ndigits)
VALUE | rb_numeric_quo (VALUE x, VALUE y)
VALUE | rb_float_numerator (VALUE x)
VALUE | rb_float_denominator (VALUE x)
VALUE | rb_gcd (VALUE x, VALUE y)
VALUE | rb_gcd_normal (VALUE self, VALUE other)

## Detailed Description

Internal header for Rational.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Definition in file rational.h.

## Macro Definition Documentation

## ◆ RRATIONAL

#define RRATIONAL | ( |  | obj | ) | ((struct RRational *)(obj))

Definition at line 24 of file rational.h.

## Function Documentation

## ◆ rb_cstr_to_rat()

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

Definition at line 2549 of file rational.c.

References num, rb_eFloatDomainError, rb_raise(), strlen(), and TRUE.

## ◆ rb_float_denominator()

VALUE rb_float_denominator | ( | VALUE | x | ) |

Definition at line 2112 of file rational.c.

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

Referenced by Init_Rational().

## ◆ rb_float_numerator()

VALUE rb_float_numerator | ( | VALUE | x | ) |

Definition at line 2092 of file rational.c.

References isinf(), isnan, and RFLOAT_VALUE.

Referenced by Init_Rational().

## ◆ rb_gcd()

VALUE rb_gcd | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1903 of file rational.c.

Referenced by Init_Rational(), and rb_int_fdiv_double().

## ◆ rb_gcd_normal()

VALUE rb_gcd_normal | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 362 of file rational.c.

## ◆ rb_lcm()

VALUE rb_lcm | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1922 of file rational.c.

Referenced by Init_Rational().

## ◆ rb_numeric_quo()

VALUE rb_numeric_quo | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 2031 of file rational.c.

References rb_complex_div(), rb_convert_type(), rb_funcallv, rb_rational_div(), T_COMPLEX, and T_RATIONAL.

Referenced by fun2(), and Init_Rational().

## ◆ rb_rational_abs()

VALUE rb_rational_abs | ( | VALUE | self | ) |

Definition at line 1236 of file rational.c.

References CLASS_OF, get_dat1, num, and rb_int_abs().

Referenced by Init_Rational().

## ◆ rb_rational_canonicalize()

VALUE rb_rational_canonicalize | ( | VALUE | x | ) |

Definition at line 2046 of file rational.c.

References get_dat1, and T_RATIONAL.

## ◆ rb_rational_cmp()

VALUE rb_rational_cmp | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 1071 of file rational.c.

References CLASS_OF, FIX2LONG, FIXNUM_P, get_dat1, get_dat2, LONG2FIX, rb_dbl_cmp(), rb_int_cmp(), rb_int_minus(), rb_int_mul(), rb_intern(), rb_num_coerce_cmp(), RFLOAT_VALUE, T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, TYPE, and ZERO.

Referenced by Init_Rational().

## ◆ rb_rational_div()

VALUE rb_rational_div | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 899 of file rational.c.

References CLASS_OF, get_dat1, get_dat2, ONE, rb_flo_div_flo(), RB_INTEGER_TYPE_P, rb_num_coerce_bin(), rb_num_zerodiv(), and T_RATIONAL.

Referenced by Init_Rational(), and rb_numeric_quo().

## ◆ rb_rational_floor()

VALUE rb_rational_floor | ( | VALUE | self,
|  | int | ndigits
| ) |  |

Definition at line 1396 of file rational.c.

References INT2NUM.

## ◆ rb_rational_hash()

VALUE rb_rational_hash | ( | VALUE | self | ) |

Definition at line 1748 of file rational.c.

References get_dat1, NUM2LONG, rb_hash(), and rb_memhash().

## ◆ rb_rational_minus()

VALUE rb_rational_minus | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 761 of file rational.c.

References CLASS_OF, DBL2NUM, get_dat1, get_dat2, rb_int_minus(), rb_int_mul(), RB_INTEGER_TYPE_P, rb_num_coerce_bin(), RFLOAT_VALUE, and T_RATIONAL.

Referenced by Init_Rational().

## ◆ rb_rational_mul()

VALUE rb_rational_mul | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 857 of file rational.c.

References DBL2NUM, get_dat1, get_dat2, ONE, RB_INTEGER_TYPE_P, rb_num_coerce_bin(), RFLOAT_VALUE, and T_RATIONAL.

Referenced by Init_Rational().

## ◆ rb_rational_plus()

VALUE rb_rational_plus | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 720 of file rational.c.

References CLASS_OF, DBL2NUM, get_dat1, get_dat2, rb_int_mul(), rb_int_plus(), RB_INTEGER_TYPE_P, rb_num_coerce_bin(), RFLOAT_VALUE, and T_RATIONAL.

Referenced by Init_Rational().

## ◆ rb_rational_pow()

VALUE rb_rational_pow | ( | VALUE | self,
|  | VALUE | other
| ) |  |

Definition at line 976 of file rational.c.

References CLASS_OF, DBL2NUM, FIXNUM_P, get_dat1, INT2FIX, INT_ZERO_P, k_exact_p, k_exact_zero_p, nan(), num, ONE, rb_float_pow(), rb_int_odd_p(), rb_int_pow(), rb_int_uminus(), RB_INTEGER_TYPE_P, rb_intern(), rb_num_coerce_bin(), rb_num_negative_p(), rb_num_zerodiv(), rb_warn(), T_BIGNUM, T_RATIONAL, and ZERO.

Referenced by rb_num_pow().

## ◆ rb_rational_reciprocal()

VALUE rb_rational_reciprocal | ( | VALUE | x | ) |

Definition at line 1884 of file rational.c.

References CLASS_OF, FALSE, and get_dat1.

## ◆ rb_rational_uminus()

VALUE rb_rational_uminus | ( | VALUE | self | ) |

Definition at line 607 of file rational.c.

References assert, CLASS_OF, get_dat1, rb_int_uminus(), and T_RATIONAL.

Referenced by Init_Rational().