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

Ruby 3.4.5p51 (2025-07-16 revision 20cda200d3ce092571d0b5d342dadca69636cb0f)

numeric.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_NUMERIC_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_NUMERIC_H
23#include "ruby/internal/attr/cold.h"
24#include "ruby/internal/attr/noreturn.h"
25#include "ruby/internal/dllexport.h"
26#include "ruby/internal/value.h"
27
35#define RB_NUM_COERCE_FUNCS_NEED_OPID 1
36
37 RBIMPL_SYMBOL_EXPORT_BEGIN()
38
39/* numeric.c */
40
41 RBIMPL_ATTR_NORETURN()
42 RBIMPL_ATTR_COLD()
48void rb_num_zerodiv(void);
49
96
107 VALUE rb_num_coerce_bin(VALUE lhs, VALUE rhs, ID op);
108
119 VALUE rb_num_coerce_cmp(VALUE lhs, VALUE rhs, ID op);
120
131 VALUE rb_num_coerce_relop(VALUE lhs, VALUE rhs, ID op);
132
143 VALUE rb_num_coerce_bit(VALUE lhs, VALUE rhs, ID op);
144
146
160 VALUE rb_num2fix(VALUE val);
161
172 VALUE rb_fix2str(VALUE val, int base);
173
174 RBIMPL_ATTR_CONST()
185 VALUE rb_dbl_cmp(double lhs, double rhs);
186
204 RUBY_EXTERN VALUE rb_int_positive_pow(long x, unsigned long y);
205
206 RBIMPL_SYMBOL_EXPORT_END()
207
208#endif /* RBIMPL_INTERN_NUMERIC_H */
cold.h
Defines RBIMPL_ATTR_COLD.
RBIMPL_ATTR_COLD
#define RBIMPL_ATTR_COLD()
Wraps (or simulates) __attribute__((cold))
Definition cold.h:34
RBIMPL_ATTR_CONST
#define RBIMPL_ATTR_CONST()
Wraps (or simulates) __attribute__((const))
Definition const.h:36
dllexport.h
Tweaking visibility of C variables/functions.
RUBY_EXTERN
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition dllexport.h:45
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_num_zerodiv
void rb_num_zerodiv(void)
Just always raises an exception.
Definition numeric.c:206
rb_num2fix
VALUE rb_num2fix(VALUE val)
Converts a numeric value into a Fixnum.
Definition numeric.c:3442
rb_fix2str
VALUE rb_fix2str(VALUE val, int base)
Generates a place-value representation of the given Fixnum, with given radix.
Definition numeric.c:3909
rb_int_positive_pow
VALUE rb_int_positive_pow(long x, unsigned long y)
Raises the passed x to the power of y.
Definition numeric.c:4559
rb_dbl_cmp
VALUE rb_dbl_cmp(double lhs, double rhs)
Compares two doubles.
Definition numeric.c:1633
rb_num_coerce_bit
VALUE rb_num_coerce_bit(VALUE lhs, VALUE rhs, ID op)
This one is optimised for bitwise operations, but the API is identical to rb_num_coerce_bin().
Definition numeric.c:4987
rb_num_coerce_relop
VALUE rb_num_coerce_relop(VALUE lhs, VALUE rhs, ID op)
Identical to rb_num_coerce_cmp(), except for return values.
Definition numeric.c:499
rb_num_coerce_cmp
VALUE rb_num_coerce_cmp(VALUE lhs, VALUE rhs, ID op)
Identical to rb_num_coerce_bin(), except for return values.
Definition numeric.c:484
rb_num_coerce_bin
VALUE rb_num_coerce_bin(VALUE lhs, VALUE rhs, ID op)
Coerced binary operation.
Definition numeric.c:477
noreturn.h
Defines RBIMPL_ATTR_NORETURN.
RBIMPL_ATTR_NORETURN
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
Definition noreturn.h:38
value.h
Defines VALUE and ID.
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40