Ruby: include/ruby/internal/intern/rational.h File Reference

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

Macros | Functions
rational.h File Reference

Public APIs related to rb_cRational. More...

`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`
`#include "ruby/internal/arithmetic/long.h"`

Go to the source code of this file.

## Macros
#define | rb_rational_raw1(x) rb_rational_raw((x), INT2FIX(1))
#define | rb_rational_raw2(x, y) rb_rational_raw((x), (y))
#define | rb_rational_new1(x) rb_rational_new((x), INT2FIX(1))
#define | rb_rational_new2(x, y) rb_rational_new((x), (y))
#define | rb_Rational1(x) rb_Rational((x), INT2FIX(1))
#define | rb_Rational2(x, y) rb_Rational((x), (y))

## Functions
VALUE | rb_rational_raw (VALUE, VALUE)
VALUE | rb_rational_new (VALUE, VALUE)
VALUE | rb_Rational (VALUE, VALUE)
VALUE | rb_rational_num (VALUE rat)
VALUE | rb_rational_den (VALUE rat)
VALUE | rb_flt_rationalize_with_prec (VALUE, VALUE)
VALUE | rb_flt_rationalize (VALUE)

## Detailed Description

Public APIs related to rb_cRational.

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.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file rational.h.

## Macro Definition Documentation

## ◆ rb_Rational1

#define rb_Rational1 | ( |  | x | ) | rb_Rational((x), INT2FIX(1))

Definition at line 37 of file rational.h.

## ◆ rb_Rational2

#define rb_Rational2 | ( |  | x,
|  |  | y
| ) |  | rb_Rational((x), (y))

Definition at line 38 of file rational.h.

## ◆ rb_rational_new1

#define rb_rational_new1 | ( |  | x | ) | rb_rational_new((x), INT2FIX(1))

Definition at line 34 of file rational.h.

## ◆ rb_rational_new2

#define rb_rational_new2 | ( |  | x,
|  |  | y
| ) |  | rb_rational_new((x), (y))

Definition at line 35 of file rational.h.

## ◆ rb_rational_raw1

#define rb_rational_raw1 | ( |  | x | ) | rb_rational_raw((x), INT2FIX(1))

Definition at line 31 of file rational.h.

## ◆ rb_rational_raw2

#define rb_rational_raw2 | ( |  | x,
|  |  | y
| ) |  | rb_rational_raw((x), (y))

Definition at line 32 of file rational.h.

## Function Documentation

## ◆ rb_flt_rationalize()

VALUE rb_flt_rationalize | ( | VALUE | flt | ) |

Definition at line 2247 of file rational.c.

References f, FLT_RADIX, INT2FIX, INT_ZERO_P, ONE, rb_int_lshift(), rb_int_minus(), rb_int_mul(), rb_int_plus(), rb_int_positive_pow(), rb_rational_new1, and rb_rational_new2.

## ◆ rb_flt_rationalize_with_prec()

VALUE rb_flt_rationalize_with_prec | ( | VALUE | flt,
|  | VALUE | prec
| ) |  |

Definition at line 2231 of file rational.c.

References f_abs, f_add, f_sub, and rb_rational_new2.

## ◆ rb_Rational()

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

Definition at line 1968 of file rational.c.

References rb_cRational.

## ◆ rb_rational_den()

VALUE rb_rational_den | ( | VALUE | rat | ) |

Definition at line 1983 of file rational.c.

Referenced by rb_str_format().

## ◆ rb_rational_new()

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

Definition at line 1962 of file rational.c.

References rb_cRational.

Referenced by date_zone_to_diff().

## ◆ rb_rational_num()

VALUE rb_rational_num | ( | VALUE | rat | ) |

Definition at line 1977 of file rational.c.

Referenced by rb_str_format().

## ◆ rb_rational_raw()

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

Definition at line 1948 of file rational.c.

References rb_cRational, rb_int_uminus(), RB_INTEGER_TYPE_P, and rb_to_int().

Referenced by rb_big_pow().