Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Macros | Functions | Variables
numeric.c File Reference
`#include "ruby/encoding.h"`
`#include "ruby/util.h"`
`#include "internal.h"`
`#include "id.h"`
`#include <assert.h>`
`#include <ctype.h>`
`#include <math.h>`
`#include <stdio.h>`

Go to the source code of this file.

## Macros
#define | FLT_RADIX 2
#define | FLT_ROUNDS 1
#define | DBL_MIN 2.2250738585072014e-308
#define | DBL_MAX 1.7976931348623157e+308
#define | DBL_MIN_EXP (-1021)
#define | DBL_MAX_EXP 1024
#define | DBL_MIN_10_EXP (-307)
#define | DBL_MAX_10_EXP 308
#define | DBL_DIG 15
#define | DBL_MANT_DIG 53
#define | DBL_EPSILON 2.2204460492503131e-16
#define | id_div idDiv
#define | id_divmod idDivmod
#define | id_to_i idTo_i
#define | id_eq idEq
#define | id_cmp idCmp
#define | NUMERR_TYPE 1
#define | NUMERR_NEGATIVE 2
#define | NUMERR_TOOLARGE 3
#define | method_basic_p(klass) rb_method_basic_definition_p(klass, mid)
#define | num_clone rb_immutable_obj_clone
#define | num_dup num_uplus
#define | flo_eq rb_float_equal
#define | flo_eql rb_float_eql
#define | FLOAT_OUT_OF_RANGE(val, type)
#define | LONG_MIN_MINUS_ONE ((double)LONG_MIN-1)
#define | LONG_MAX_PLUS_ONE (2*(double)(LONG_MAX/2+1))
#define | ULONG_MAX_PLUS_ONE (2*(double)(ULONG_MAX/2+1))
#define | LONG_MIN_MINUS_ONE_IS_LESS_THAN(n)
#define | int_succ rb_int_succ
#define | int_pred rb_int_pred
#define | SQRT_LONG_MAX HALF_LONG_MSB
#define | FIT_SQRT_LONG(n) (((n)<SQRT_LONG_MAX)&&((n)>=-SQRT_LONG_MAX))
#define | DEFINE_INT_SQRT(rettype, prefix, argtype)
#define | RB_ULONG_IN_DOUBLE_P(n) 1
#define | RB_ULONG_TO_DOUBLE(n) (double)(n)
#define | RB_ULONG unsigned long
#define | domain_error(msg) rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg)
#define | rb_intern(str) rb_intern_const(str)

## Functions
double | round (double x)
VALUE | rb_int_floor (VALUE num, int ndigits)
VALUE | rb_int_ceil (VALUE num, int ndigits)
void | rb_num_zerodiv (void)
enum ruby_num_rounding_mode | rb_num_get_rounding_option (VALUE opts)
int | rb_num_to_uint (VALUE val, unsigned int *ret)
int | rb_int_positive_p (VALUE num)
int | rb_int_negative_p (VALUE num)
int | rb_num_negative_p (VALUE num)
| NORETURN (static void num_funcall_op_1_recursion(VALUE x, ID func, VALUE y))
| NORETURN (static void coerce_failed(VALUE x, VALUE y))
VALUE | rb_num_coerce_bin (VALUE x, VALUE y, ID func)
VALUE | rb_num_coerce_cmp (VALUE x, VALUE y, ID func)
VALUE | rb_num_coerce_relop (VALUE x, VALUE y, ID func)
VALUE | rb_float_new_in_heap (double d)
VALUE | rb_float_uminus (VALUE flt)
VALUE | rb_float_plus (VALUE x, VALUE y)
VALUE | rb_float_mul (VALUE x, VALUE y)
MJIT_FUNC_EXPORTED VALUE | rb_flo_div_flo (VALUE x, VALUE y)
VALUE | rb_float_div (VALUE x, VALUE y)
MJIT_FUNC_EXPORTED double | ruby_float_mod (double x, double y)
VALUE | rb_float_pow (VALUE x, VALUE y)
MJIT_FUNC_EXPORTED VALUE | rb_float_equal (VALUE x, VALUE y)
VALUE | rb_dbl_cmp (double a, double b)
MJIT_FUNC_EXPORTED int | rb_float_cmp (VALUE x, VALUE y)
VALUE | rb_float_gt (VALUE x, VALUE y)
MJIT_FUNC_EXPORTED VALUE | rb_float_eql (VALUE x, VALUE y)
VALUE | rb_float_abs (VALUE flt)
VALUE | rb_flo_is_infinite_p (VALUE num)
VALUE | rb_flo_is_finite_p (VALUE num)
VALUE | rb_float_ceil (VALUE num, int ndigits)
VALUE | rb_int_truncate (VALUE num, int ndigits)
double | ruby_float_step_size (double beg, double end, double unit, int excl)
int | ruby_float_step (VALUE from, VALUE to, VALUE step, int excl, int allow_endless)
VALUE | ruby_num_interval_step_size (VALUE from, VALUE to, VALUE step, int excl)
long | rb_num2long (VALUE val)
unsigned long | rb_num2ulong (VALUE val)
long | rb_num2int (VALUE val)
long | rb_fix2int (VALUE val)
| NORETURN (static void rb_out_of_short(SIGNED_VALUE num))
short | rb_num2short (VALUE val)
short | rb_fix2short (VALUE val)
unsigned short | rb_num2ushort (VALUE val)
unsigned short | rb_fix2ushort (VALUE val)
VALUE | rb_num2fix (VALUE val)
VALUE | rb_int_odd_p (VALUE num)
VALUE | rb_int_succ (VALUE num)
VALUE | rb_enc_uint_chr (unsigned int code, rb_encoding *enc)
VALUE | rb_int_uminus (VALUE num)
VALUE | rb_fix2str (VALUE x, int base)
VALUE | rb_int2str (VALUE x, int base)
VALUE | rb_fix_plus (VALUE x, VALUE y)
VALUE | rb_int_plus (VALUE x, VALUE y)
VALUE | rb_int_minus (VALUE x, VALUE y)
VALUE | rb_int_mul (VALUE x, VALUE y)
double | rb_int_fdiv_double (VALUE x, VALUE y)
VALUE | rb_int_fdiv (VALUE x, VALUE y)
VALUE | rb_int_div (VALUE x, VALUE y)
VALUE | rb_int_idiv (VALUE x, VALUE y)
VALUE | rb_int_modulo (VALUE x, VALUE y)
VALUE | rb_int_divmod (VALUE x, VALUE y)
VALUE | rb_int_positive_pow (long x, unsigned long y)
VALUE | rb_int_pow (VALUE x, VALUE y)
VALUE | rb_num_pow (VALUE x, VALUE y)
VALUE | rb_int_equal (VALUE x, VALUE y)
VALUE | rb_int_cmp (VALUE x, VALUE y)
VALUE | rb_int_gt (VALUE x, VALUE y)
VALUE | rb_int_ge (VALUE x, VALUE y)
VALUE | rb_num_coerce_bit (VALUE x, VALUE y, ID func)
VALUE | rb_int_and (VALUE x, VALUE y)
VALUE | rb_int_lshift (VALUE x, VALUE y)
MJIT_FUNC_EXPORTED VALUE | rb_fix_aref (VALUE fix, VALUE idx)
VALUE | rb_int_abs (VALUE num)
VALUE | rb_big_isqrt (VALUE)
void | Init_Numeric (void)
double | rb_float_value (VALUE v)
VALUE | rb_float_new (double d)

## Variables
const union bytesequence4_or_float | rb_infinity = {{0x00, 0x00, 0x80, 0x7f}}
const union bytesequence4_or_float | rb_nan = {{0x00, 0x00, 0xc0, 0x7f}}
VALUE | rb_cNumeric
VALUE | rb_cFloat
VALUE | rb_cInteger
VALUE | rb_eZeroDivError
VALUE | rb_eFloatDomainError

## Macro Definition Documentation

## ◆ DBL_DIG

#define DBL_DIG 15

Definition at line 55 of file numeric.c.

## ◆ DBL_EPSILON

#define DBL_EPSILON 2.2204460492503131e-16

Definition at line 61 of file numeric.c.

## ◆ DBL_MANT_DIG

#define DBL_MANT_DIG 53

Definition at line 58 of file numeric.c.

## ◆ DBL_MAX

#define DBL_MAX 1.7976931348623157e+308

Definition at line 40 of file numeric.c.

## ◆ DBL_MAX_10_EXP

#define DBL_MAX_10_EXP 308

Definition at line 52 of file numeric.c.

## ◆ DBL_MAX_EXP

#define DBL_MAX_EXP 1024

Definition at line 46 of file numeric.c.

## ◆ DBL_MIN

#define DBL_MIN 2.2250738585072014e-308

Definition at line 37 of file numeric.c.

## ◆ DBL_MIN_10_EXP

#define DBL_MIN_10_EXP (-307)

Definition at line 49 of file numeric.c.

## ◆ DBL_MIN_EXP

#define DBL_MIN_EXP (-1021)

Definition at line 43 of file numeric.c.

## ◆ DEFINE_INT_SQRT

#define DEFINE_INT_SQRT | ( |  | rettype,
|  |  | prefix,
|  |  | argtype
| ) |  |

Value:
rettype \
prefix##_isqrt(argtype n) \
{ \
if (!argtype##_IN_DOUBLE_P(n)) { \
unsigned int b = bit_length(n); \
argtype t; \
rettype x = (rettype)(n >> (b/2+1)); \
x |= ((rettype)1LU << (b-1)/2); \
while ((t = n/x) < (argtype)x) x = (rettype)((x + t) >> 1); \
return x; \
} \
return (rettype)sqrt(argtype##_TO_DOUBLE(n)); \
}

Definition at line 5360 of file numeric.c.

## ◆ domain_error

#define domain_error | ( |  | msg | ) | rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg)

Definition at line 5398 of file numeric.c.

## ◆ FIT_SQRT_LONG

#define FIT_SQRT_LONG | ( |  | n | ) | (((n)<SQRT_LONG_MAX)&&((n)>=-SQRT_LONG_MAX))

Definition at line 3663 of file numeric.c.

## ◆ flo_eq

#define flo_eq rb_float_equal

Definition at line 1406 of file numeric.c.

## ◆ flo_eql

#define flo_eql rb_float_eql

Definition at line 1668 of file numeric.c.

## ◆ FLOAT_OUT_OF_RANGE

#define FLOAT_OUT_OF_RANGE | ( |  | val,
|  |  | type
| ) |  |

Value:
do { \
char buf[24]; \
rb_raise(rb_eRangeError, "float %s out of range of "type, \
out_of_range_float(&buf, (val))); \
} while (0)

Definition at line 2834 of file numeric.c.

## ◆ FLT_RADIX

#define FLT_RADIX 2

Definition at line 31 of file numeric.c.

## ◆ FLT_ROUNDS

#define FLT_ROUNDS 1

Definition at line 34 of file numeric.c.

## ◆ id_cmp

#define id_cmp idCmp

Definition at line 179 of file numeric.c.

## ◆ id_div

#define id_div idDiv

Definition at line 175 of file numeric.c.

## ◆ id_divmod

#define id_divmod idDivmod

Definition at line 176 of file numeric.c.

## ◆ id_eq

#define id_eq idEq

Definition at line 178 of file numeric.c.

## ◆ id_to_i

#define id_to_i idTo_i

Definition at line 177 of file numeric.c.

## ◆ int_pred

#define int_pred rb_int_pred

Definition at line 3359 of file numeric.c.

## ◆ int_succ

#define int_succ rb_int_succ

Definition at line 3333 of file numeric.c.

## ◆ LONG_MAX_PLUS_ONE

#define LONG_MAX_PLUS_ONE (2*(double)(LONG_MAX/2+1))

Definition at line 2841 of file numeric.c.

## ◆ LONG_MIN_MINUS_ONE

#define LONG_MIN_MINUS_ONE ((double)LONG_MIN-1)

Definition at line 2840 of file numeric.c.

## ◆ LONG_MIN_MINUS_ONE_IS_LESS_THAN

#define LONG_MIN_MINUS_ONE_IS_LESS_THAN | ( |  | n | ) |

Value:
(LONG_MIN_MINUS_ONE == (double)LONG_MIN ? \
LONG_MIN <= (n): \
LONG_MIN_MINUS_ONE < (n))

Definition at line 2843 of file numeric.c.

## ◆ method_basic_p

#define method_basic_p | ( |  | klass | ) | rb_method_basic_definition_p(klass, mid)

Definition at line 274 of file numeric.c.

## ◆ num_clone

#define num_clone rb_immutable_obj_clone

Definition at line 508 of file numeric.c.

## ◆ num_dup

#define num_dup num_uplus

Definition at line 524 of file numeric.c.

## ◆ NUMERR_NEGATIVE

#define NUMERR_NEGATIVE 2

## ◆ NUMERR_TOOLARGE

#define NUMERR_TOOLARGE 3

## ◆ NUMERR_TYPE

#define NUMERR_TYPE 1

## ◆ rb_intern

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

## ◆ RB_ULONG

#define RB_ULONG unsigned long

Definition at line 5381 of file numeric.c.

## ◆ RB_ULONG_IN_DOUBLE_P

#define RB_ULONG_IN_DOUBLE_P | ( |  | n | ) | 1

Definition at line 5378 of file numeric.c.

## ◆ RB_ULONG_TO_DOUBLE

#define RB_ULONG_TO_DOUBLE | ( |  | n | ) | (double)(n)

Definition at line 5380 of file numeric.c.

## ◆ SQRT_LONG_MAX

#define SQRT_LONG_MAX HALF_LONG_MSB

Definition at line 3661 of file numeric.c.

## ◆ ULONG_MAX_PLUS_ONE

#define ULONG_MAX_PLUS_ONE (2*(double)(ULONG_MAX/2+1))

Definition at line 2842 of file numeric.c.

## Function Documentation

## ◆ Init_Numeric()

void Init_Numeric | ( | void |  | ) |

Definition at line 5557 of file numeric.c.

## ◆ NORETURN() [1/3]

NORETURN | ( | static void | coerce_failedVALUE x, VALUE y | ) |

## ◆ NORETURN() [2/3]

NORETURN | ( | static void | num_funcall_op_1_recursionVALUE x, ID func, VALUE y | ) |

## ◆ NORETURN() [3/3]

NORETURN | ( | static void | rb_out_of_shortSIGNED_VALUE num | ) |

## ◆ rb_big_isqrt()

VALUE rb_big_isqrt | ( | VALUE |  | ) |

Definition at line 6911 of file bignum.c.

References BDIGIT, BDIGITS, BIGNUM_LEN, len, n, and rb_bdigit_dbl_isqrt.

## ◆ rb_dbl_cmp()

VALUE rb_dbl_cmp | ( | double | a,
|  | double | b
| ) |  |

Definition at line 1431 of file numeric.c.

References INT2FIX, isnan, and Qnil.

## ◆ rb_enc_uint_chr()

VALUE rb_enc_uint_chr | ( | unsigned int | code,
|  | rb_encoding * | enc
| ) |  |

Definition at line 3375 of file numeric.c.

References n, ONIGERR_INVALID_CODE_POINT_VALUE, ONIGERR_TOO_BIG_WIDE_CHAR_VALUE, rb_enc_codelen(), rb_enc_mbcput, rb_enc_name, rb_enc_precise_mbclen(), rb_enc_str_new(), rb_eRangeError, rb_raise(), RSTRING_END, RSTRING_PTR, and str.

Referenced by rb_io_ungetc().

## ◆ rb_fix2int()

long rb_fix2int | ( | VALUE | val | ) |

Definition at line 3003 of file numeric.c.

References FIX2INT.

## ◆ rb_fix2short()

short rb_fix2short | ( | VALUE | val | ) |

Definition at line 3050 of file numeric.c.

References FIX2LONG, FIXNUM_P, and rb_num2long().

## ◆ rb_fix2str()

VALUE rb_fix2str | ( | VALUE | x,
|  | int | base
| ) |  |

Definition at line 3508 of file numeric.c.

References buf, CHAR_BIT, FIX2LONG, int, long, neg, rb_bug(), rb_eArgError, rb_raise(), rb_usascii_str_new, rb_usascii_str_new2, ruby_digitmap, and SIZEOF_VALUE.

Referenced by rb_int2str().

## ◆ rb_fix2ushort()

unsigned short rb_fix2ushort | ( | VALUE | val | ) |

Definition at line 3069 of file numeric.c.

References FIX2ULONG, FIXNUM_P, and rb_num2ushort().

## ◆ rb_fix_aref()

MJIT_FUNC_EXPORTED VALUE rb_fix_aref | ( | VALUE | fix,
|  | VALUE | idx
| ) |  |

Definition at line 4642 of file numeric.c.

References BIGNUM_SIGN, CHAR_BIT, FIX2LONG, FIXNUM_P, i, INT2FIX, L, rb_big_norm(), rb_to_int(), and SIZEOF_LONG.

## ◆ rb_fix_plus()

VALUE rb_fix_plus | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3604 of file numeric.c.

## ◆ rb_flo_div_flo()

MJIT_FUNC_EXPORTED VALUE rb_flo_div_flo | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1110 of file numeric.c.

References RFLOAT_VALUE.

## ◆ rb_flo_is_finite_p()

VALUE rb_flo_is_finite_p | ( | VALUE | num | ) |

Definition at line 1770 of file numeric.c.

References isfinite, isinf, isnan, Qfalse, Qtrue, and RFLOAT_VALUE.

## ◆ rb_flo_is_infinite_p()

VALUE rb_flo_is_infinite_p | ( | VALUE | num | ) |

Definition at line 1750 of file numeric.c.

References INT2FIX, isinf, Qnil, and RFLOAT_VALUE.

## ◆ rb_float_abs()

VALUE rb_float_abs | ( | VALUE | flt | ) |

Definition at line 1698 of file numeric.c.

References DBL2NUM, fabs(), and RFLOAT_VALUE.

## ◆ rb_float_ceil()

VALUE rb_float_ceil | ( | VALUE | num,
|  | int | ndigits
| ) |  |

Definition at line 2017 of file numeric.c.

References DBL2NUM, f, frexp(), INT2FIX, and RFLOAT_VALUE.

## ◆ rb_float_cmp()

MJIT_FUNC_EXPORTED int rb_float_cmp | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1487 of file numeric.c.

References NUM2INT.

## ◆ rb_float_div()

VALUE rb_float_div | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1126 of file numeric.c.

References FIX2LONG, rb_big2dbl(), rb_num_coerce_bin(), RB_TYPE_P, RFLOAT_VALUE, T_BIGNUM, T_FIXNUM, and T_FLOAT.

Referenced by fun2().

## ◆ rb_float_eql()

MJIT_FUNC_EXPORTED VALUE rb_float_eql | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1654 of file numeric.c.

References isnan, Qfalse, Qtrue, RB_TYPE_P, RFLOAT_VALUE, and T_FLOAT.

## ◆ rb_float_equal()

MJIT_FUNC_EXPORTED VALUE rb_float_equal | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1383 of file numeric.c.

References isnan, Qfalse, rb_integer_float_eq(), RB_TYPE_P, RFLOAT_VALUE, T_BIGNUM, T_FIXNUM, and T_FLOAT.

## ◆ rb_float_gt()

VALUE rb_float_gt | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1503 of file numeric.c.

References FIX2LONG, FIXNUM_P, isnan, Qfalse, Qtrue, rb_integer_float_cmp(), rb_num_coerce_relop(), RB_TYPE_P, RFLOAT_VALUE, T_BIGNUM, T_FIXNUM, and T_FLOAT.

## ◆ rb_float_mul()

VALUE rb_float_mul | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1072 of file numeric.c.

References DBL2NUM, FIX2LONG, rb_big2dbl(), rb_num_coerce_bin(), RB_TYPE_P, RFLOAT_VALUE, T_BIGNUM, T_FIXNUM, and T_FLOAT.

## ◆ rb_float_new()

VALUE rb_float_new | ( | double | d | ) |

Definition at line 5841 of file numeric.c.

## ◆ rb_float_new_in_heap()

VALUE rb_float_new_in_heap | ( | double | d | ) |

Definition at line 895 of file numeric.c.

References FL_WB_PROTECTED, NEWOBJ_OF, OBJ_FREEZE, rb_cFloat, RGENGC_WB_PROTECTED_FLOAT, and T_FLOAT.

## ◆ rb_float_plus()

VALUE rb_float_plus | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1024 of file numeric.c.

References DBL2NUM, FIX2LONG, rb_big2dbl(), rb_num_coerce_bin(), RB_TYPE_P, RFLOAT_VALUE, T_BIGNUM, T_FIXNUM, and T_FLOAT.

## ◆ rb_float_pow()

VALUE rb_float_pow | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1298 of file numeric.c.

References DBL2NUM, double, FIX2LONG, idPow, pow(), rb_big2dbl(), rb_dbl_complex_new_polar_pi(), rb_num_coerce_bin(), RB_TYPE_P, RFLOAT_VALUE, round(), T_BIGNUM, T_FIXNUM, and T_FLOAT.

Referenced by rb_num_pow().

## ◆ rb_float_uminus()

VALUE rb_float_uminus | ( | VALUE | flt | ) |

Definition at line 1011 of file numeric.c.

References DBL2NUM, and RFLOAT_VALUE.

## ◆ rb_float_value()

double rb_float_value | ( | VALUE | v | ) |

Definition at line 5834 of file numeric.c.

## ◆ rb_int2str()

VALUE rb_int2str | ( | VALUE | x,
|  | int | base
| ) |  |

Definition at line 3562 of file numeric.c.

References FIXNUM_P, rb_any_to_s(), rb_big2str(), rb_fix2str(), RB_TYPE_P, and T_BIGNUM.

## ◆ rb_int_abs()

VALUE rb_int_abs | ( | VALUE | num | ) |

Definition at line 4855 of file numeric.c.

References FIXNUM_P.

Referenced by rb_rational_abs().

## ◆ rb_int_and()

VALUE rb_int_and | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4467 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_ceil()

VALUE rb_int_ceil | ( | VALUE | num,
|  | int | ndigits
| ) |  |

Definition at line 2160 of file numeric.c.

References f.

## ◆ rb_int_cmp()

VALUE rb_int_cmp | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4212 of file numeric.c.

References FIXNUM_P.

Referenced by rb_rational_cmp().

## ◆ rb_int_div()

VALUE rb_int_div | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3816 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_divmod()

VALUE rb_int_divmod | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3963 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_equal()

VALUE rb_int_equal | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4163 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_fdiv()

VALUE rb_int_fdiv | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3761 of file numeric.c.

References DBL2NUM, Qnil, rb_int_fdiv_double(), and RB_INTEGER_TYPE_P.

## ◆ rb_int_fdiv_double()

double rb_int_fdiv_double | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3728 of file numeric.c.

References FIXNUM_P, FIXNUM_ZERO_P, rb_gcd(), rb_int_idiv(), and RB_INTEGER_TYPE_P.

Referenced by rb_int_fdiv().

## ◆ rb_int_floor()

VALUE rb_int_floor | ( | VALUE | num,
|  | int | ndigits
| ) |  |

Definition at line 2137 of file numeric.c.

References f.

## ◆ rb_int_ge()

VALUE rb_int_ge | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4292 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_gt()

VALUE rb_int_gt | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4252 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_idiv()

VALUE rb_int_idiv | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3843 of file numeric.c.

References FIXNUM_P.

Referenced by rb_int_fdiv_double().

## ◆ rb_int_lshift()

VALUE rb_int_lshift | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4583 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_minus()

VALUE rb_int_minus | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3649 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_modulo()

VALUE rb_int_modulo | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3886 of file numeric.c.

References FIXNUM_P.

Referenced by rb_io_ungetbyte().

## ◆ rb_int_mul()

VALUE rb_int_mul | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3699 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_negative_p()

int rb_int_negative_p | ( | VALUE | num | ) |

Definition at line 307 of file numeric.c.

Referenced by rb_int_powm().

## ◆ rb_int_odd_p()

VALUE rb_int_odd_p | ( | VALUE | num | ) |

Definition at line 3222 of file numeric.c.

References FIXNUM_P, INT2FIX, Qfalse, Qtrue, rb_big_odd_p(), rb_funcall, RB_TYPE_P, and T_BIGNUM.

## ◆ rb_int_plus()

VALUE rb_int_plus | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 3610 of file numeric.c.

References FIXNUM_P.

## ◆ rb_int_positive_p()

int rb_int_positive_p | ( | VALUE | num | ) |

Definition at line 301 of file numeric.c.

## ◆ rb_int_positive_pow()

VALUE rb_int_positive_pow | ( | long | x,
|  | unsigned long | y
| ) |  |

Definition at line 4033 of file numeric.c.

## ◆ rb_int_pow()

VALUE rb_int_pow | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4106 of file numeric.c.

References FIXNUM_P.

Referenced by rb_int_powm(), and rb_num_pow().

## ◆ rb_int_succ()

VALUE rb_int_succ | ( | VALUE | num | ) |

Definition at line 3321 of file numeric.c.

References FIX2LONG, FIXNUM_P, i, INT2FIX, LONG2NUM, rb_big_plus(), RB_TYPE_P, and T_BIGNUM.

## ◆ rb_int_truncate()

VALUE rb_int_truncate | ( | VALUE | num,
|  | int | ndigits
| ) |  |

Definition at line 2184 of file numeric.c.

References f.

## ◆ rb_int_uminus()

VALUE rb_int_uminus | ( | VALUE | num | ) |

Definition at line 3479 of file numeric.c.

References FIXNUM_P.

Referenced by rb_int_powm().

## ◆ rb_num2fix()

VALUE rb_num2fix | ( | VALUE | val | ) |

Definition at line 3083 of file numeric.c.

References FIXABLE, FIXNUM_P, LONG2FIX, rb_eRangeError, rb_num2long(), rb_raise(), and v.

## ◆ rb_num2int()

long rb_num2int | ( | VALUE | val | ) |

Definition at line 2997 of file numeric.c.

References rb_num2long().

## ◆ rb_num2long()

long rb_num2long | ( | VALUE | val | ) |

Definition at line 2849 of file numeric.c.

References FIX2LONG, FIXNUM_P, FLOAT_OUT_OF_RANGE, LONG_MAX_PLUS_ONE, LONG_MIN_MINUS_ONE_IS_LESS_THAN, NIL_P, rb_big2long(), rb_eTypeError, rb_raise(), rb_to_int(), RB_TYPE_P, RFLOAT_VALUE, T_BIGNUM, and T_FLOAT.

Referenced by rb_fix2short(), rb_num2fix(), rb_num2int(), and rb_num2short().

## ◆ rb_num2short()

short rb_num2short | ( | VALUE | val | ) |

Definition at line 3041 of file numeric.c.

References rb_num2long().

## ◆ rb_num2ulong()

unsigned long rb_num2ulong | ( | VALUE | val | ) |

Definition at line 2918 of file numeric.c.

## ◆ rb_num2ushort()

unsigned short rb_num2ushort | ( | VALUE | val | ) |

Definition at line 3059 of file numeric.c.

Referenced by rb_fix2ushort().

## ◆ rb_num_coerce_bin()

VALUE rb_num_coerce_bin | ( | VALUE | x,
|  | VALUE | y,
|  | ID | func
| ) |  |

Definition at line 446 of file numeric.c.

Referenced by rb_big_divmod(), rb_big_modulo(), rb_big_mul(), rb_big_remainder(), rb_float_div(), rb_float_mul(), rb_float_plus(), and rb_float_pow().

## ◆ rb_num_coerce_bit()

VALUE rb_num_coerce_bit | ( | VALUE | x,
|  | VALUE | y,
|  | ID | func
| ) |  |

Definition at line 4426 of file numeric.c.

Referenced by rb_big_and(), rb_big_or(), and rb_big_xor().

## ◆ rb_num_coerce_cmp()

VALUE rb_num_coerce_cmp | ( | VALUE | x,
|  | VALUE | y,
|  | ID | func
| ) |  |

Definition at line 453 of file numeric.c.

## ◆ rb_num_coerce_relop()

VALUE rb_num_coerce_relop | ( | VALUE | x,
|  | VALUE | y,
|  | ID | func
| ) |  |

Definition at line 461 of file numeric.c.

References y0().

Referenced by rb_float_gt().

## ◆ rb_num_get_rounding_option()

enum ruby_num_rounding_mode rb_num_get_rounding_option | ( | VALUE | opts | ) |

Definition at line 200 of file numeric.c.

References NIL_P, rb_get_kwargs(), rb_intern_const, str, and SYMBOL_P.

## ◆ rb_num_negative_p()

int rb_num_negative_p | ( | VALUE | num | ) |

Definition at line 313 of file numeric.c.

## ◆ rb_num_pow()

VALUE rb_num_pow | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4118 of file numeric.c.

References BUILTIN_TYPE, NIL_P, Qnil, rb_complex_pow(), rb_float_pow(), RB_FLOAT_TYPE_P, rb_int_pow(), rb_rational_pow(), SPECIAL_CONST_P, T_COMPLEX, and T_RATIONAL.

## ◆ rb_num_to_uint()

int rb_num_to_uint | ( | VALUE | val,
|  | unsigned int * | ret
| ) |  |

Definition at line 244 of file numeric.c.

References BIGNUM_NEGATIVE_P, FIX2LONG, FIXNUM_P, int, NULL, NUMERR_NEGATIVE, NUMERR_TOOLARGE, NUMERR_TYPE, rb_absint_size(), rb_big2ulong(), RB_TYPE_P, T_BIGNUM, UINT_MAX, and v.

Referenced by rb_str_concat().

## ◆ rb_num_zerodiv()

void rb_num_zerodiv | ( | void |  | ) |

Definition at line 194 of file numeric.c.

References rb_eZeroDivError, and rb_raise().

Referenced by rb_big_divrem_normal(), and rb_int_powm().

## ◆ round()

double round | ( | double | x | ) |

Definition at line 80 of file numeric.c.

References ceil(), f, and floor().

Referenced by rb_float_pow().

## ◆ ruby_float_mod()

MJIT_FUNC_EXPORTED double ruby_float_mod | ( | double | x,
|  | double | y
| ) |  |

Definition at line 1207 of file numeric.c.

References mod.

## ◆ ruby_float_step()

int ruby_float_step | ( | VALUE | from,
|  | VALUE | to,
|  | VALUE | step,
|  | int | excl,
|  | int | allow_endless
| ) |  |

Definition at line 2524 of file numeric.c.

References DBL2NUM, FALSE, HUGE_VAL, i, isinf, n, NIL_P, NUM2DBL, RB_TYPE_P, rb_yield(), ruby_float_step_size(), T_FLOAT, and TRUE.

## ◆ ruby_float_step_size()

double ruby_float_step_size | ( | double | beg,
|  | double | end,
|  | double | unit,
|  | int | excl
| ) |  |

Definition at line 2495 of file numeric.c.

References DBL_EPSILON, err, fabs(), floor(), HUGE_VAL, isinf, and n.

Referenced by ruby_float_step().

## ◆ ruby_num_interval_step_size()

VALUE ruby_num_interval_step_size | ( | VALUE | from,
|  | VALUE | to,
|  | VALUE | step,
|  | int | excl
| ) |  |

Definition at line 2555 of file numeric.c.

References FIXNUM_P.

## Variable Documentation

## ◆ rb_infinity

const union bytesequence4_or_float rb_infinity = {{0x00, 0x00, 0x80, 0x7f}}

Definition at line 66 of file numeric.c.

## ◆ rb_nan

const union bytesequence4_or_float rb_nan = {{0x00, 0x00, 0xc0, 0x7f}}

Definition at line 73 of file numeric.c.

rb_eRangeError
VALUE rb_eRangeError
Definition: error.c:926
sqrt
double sqrt(double)
LONG_MIN_MINUS_ONE
#define LONG_MIN_MINUS_ONE
Definition: numeric.c:2840
double
double
Definition: rb_mjit_min_header-2.7.0.h:5923
LONG_MIN
#define LONG_MIN
Definition: ruby.h:224
buf
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4322
n
const char size_t n
Definition: rb_mjit_min_header-2.7.0.h:5456
bit_length
#define bit_length(x)
Definition: internal.h:680
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:39