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

Ruby 3.4.8p72 (2025-12-17 revision 995b59f66677d44767ce9faac6957e5543617ff9)

rational.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_RATIONAL_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_RATIONAL_H
23#include "ruby/internal/attr/pure.h"
24#include "ruby/internal/dllexport.h"
25#include "ruby/internal/value.h"
26#include "ruby/internal/arithmetic/long.h" /* INT2FIX is here. */
27
28 RBIMPL_SYMBOL_EXPORT_BEGIN()
29
30/* rational.c */
31
32
42 VALUE rb_rational_raw(VALUE num, VALUE den);
43
51#define rb_rational_raw1(x) rb_rational_raw((x), INT2FIX(1))
52
54#define rb_rational_raw2(x,y) rb_rational_raw((x), (y))
55
65 VALUE rb_rational_new(VALUE num, VALUE den);
66
74#define rb_rational_new1(x) rb_rational_new((x), INT2FIX(1))
75
77#define rb_rational_new2(x,y) rb_rational_new((x), (y))
78
106 VALUE rb_Rational(VALUE num, VALUE den);
107
116#define rb_Rational1(x) rb_Rational((x), INT2FIX(1))
117
119#define rb_Rational2(x,y) rb_Rational((x), (y))
120
121 RBIMPL_ATTR_PURE()
128 VALUE rb_rational_num(VALUE rat);
129
130 RBIMPL_ATTR_PURE()
138 VALUE rb_rational_den(VALUE rat);
139
159 VALUE rb_flt_rationalize_with_prec(VALUE flt, VALUE prec);
160
168 VALUE rb_flt_rationalize(VALUE flt);
169
170 RBIMPL_SYMBOL_EXPORT_END()
171
172#endif /* RBIMPL_INTERN_RATIONAL_H */
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
rb_rational_raw
VALUE rb_rational_raw(VALUE num, VALUE den)
Identical to rb_rational_new(), except it skips argument validations.
Definition rational.c:1960
rb_rational_new
VALUE rb_rational_new(VALUE num, VALUE den)
Constructs a Rational, with reduction.
Definition rational.c:1974
rb_Rational
VALUE rb_Rational(VALUE num, VALUE den)
Converts various values into a Rational.
Definition rational.c:1980
rb_rational_num
VALUE rb_rational_num(VALUE rat)
Queries the numerator of the passed Rational.
Definition rational.c:1989
rb_flt_rationalize
VALUE rb_flt_rationalize(VALUE flt)
Identical to rb_flt_rationalize_with_prec(), except it auto-detects appropriate precision depending o...
Definition rational.c:2242
rb_flt_rationalize_with_prec
VALUE rb_flt_rationalize_with_prec(VALUE flt, VALUE prec)
Simplified approximation of a float.
Definition rational.c:2226
rb_rational_den
VALUE rb_rational_den(VALUE rat)
Queries the denominator of the passed Rational.
Definition rational.c:1995
long.h
Arithmetic conversion between C's long and Ruby's.
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition pure.h:33
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40