Ruby
2.5.0dev(2017-10-22revision60238)
|
#include "internal.h"
#include "ruby/util.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_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 ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2)) |
#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) |
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 |
#define DBL_DIG 15 |
Definition at line 54 of file numeric.c.
Referenced by rb_cstr_to_dbl(), and ruby_strtod().
#define DBL_EPSILON 2.2204460492503131e-16 |
Definition at line 60 of file numeric.c.
Referenced by nextafter().
#define DBL_MAX 1.7976931348623157e+308 |
Definition at line 39 of file numeric.c.
Referenced by nextafter().
#define DBL_MAX_EXP 1024 |
Definition at line 45 of file numeric.c.
Referenced by ruby_hdtoa().
#define DBL_MIN 2.2250738585072014e-308 |
Definition at line 36 of file numeric.c.
Referenced by nextafter().
#define DBL_MIN_EXP (-1021) |
Definition at line 42 of file numeric.c.
Referenced by nextafter().
#define DEFINE_INT_SQRT | ( | rettype, | |
prefix, | |||
argtype | |||
) |
#define domain_error | ( | msg | ) | rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg) |
#define FIT_SQRT_LONG | ( | n | ) | (((n)<SQRT_LONG_MAX)&&((n)>=-SQRT_LONG_MAX)) |
#define flo_eq rb_float_equal |
#define flo_eql rb_float_eql |
#define FLOAT_OUT_OF_RANGE | ( | val, | |
type | |||
) |
Definition at line 2784 of file numeric.c.
Referenced by rb_num2fix(), and rb_num2long().
#define int_pred rb_int_pred |
#define int_succ rb_int_succ |
#define LONG_MAX_PLUS_ONE (2*(double)(LONG_MAX/2+1)) |
Definition at line 2791 of file numeric.c.
Referenced by rb_num2long().
#define LONG_MIN_MINUS_ONE_IS_LESS_THAN | ( | n | ) |
Definition at line 2793 of file numeric.c.
Referenced by rb_num2long().
#define method_basic_p | ( | klass | ) | rb_method_basic_definition_p(klass, mid) |
#define num_clone rb_immutable_obj_clone |
#define NUMERR_NEGATIVE 2 |
Referenced by rb_num_to_uint().
#define NUMERR_TOOLARGE 3 |
Referenced by rb_num_to_uint().
#define NUMERR_TYPE 1 |
Referenced by rb_num_to_uint().
#define rb_intern | ( | str | ) | rb_intern_const(str) |
#define SQRT_LONG_MAX ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2)) |
NORETURN | ( | static void | coerce_failedVALUE x, VALUE y | ) |
Referenced by rb_fix2int().
NORETURN | ( | static void | rb_out_of_shortSIGNED_VALUE num | ) |
Definition at line 6840 of file bignum.c.
References BDIGIT, BDIGITS, BIGNUM_LEN, and rb_bdigit_dbl_isqrt.
VALUE rb_dbl_cmp | ( | double | a, |
double | b | ||
) |
VALUE rb_dbl_hash | ( | double | d | ) |
Definition at line 1419 of file numeric.c.
References LONG2FIX, and rb_dbl_long_hash().
VALUE rb_enc_uint_chr | ( | unsigned int | code, |
rb_encoding * | enc | ||
) |
Definition at line 3283 of file numeric.c.
References 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, and RSTRING_PTR.
Referenced by rb_io_ungetc().
long rb_fix2int | ( | VALUE | val | ) |
Definition at line 2953 of file numeric.c.
References FIX2INT, and NORETURN().
short rb_fix2short | ( | VALUE | val | ) |
Definition at line 3000 of file numeric.c.
References FIX2LONG, FIXNUM_P, and rb_num2long().
Definition at line 3417 of file numeric.c.
References buf, CHAR_BIT, FIX2LONG, neg, rb_bug(), rb_eArgError, rb_raise(), rb_usascii_str_new(), rb_usascii_str_new2, ruby_digitmap, SIZEOF_VALUE, and val.
Referenced by rb_int2str().
unsigned short rb_fix2ushort | ( | VALUE | val | ) |
Definition at line 3019 of file numeric.c.
References FIX2ULONG, FIXNUM_P, and rb_num2ushort().
Definition at line 1692 of file numeric.c.
References DBL2NUM, RFLOAT_VALUE, and val.
Definition at line 1378 of file numeric.c.
References isnan, Qfalse, rb_integer_float_eq(), RB_TYPE_P, RFLOAT_VALUE, T_BIGNUM, T_FIXNUM, and T_FLOAT.
Definition at line 1497 of file numeric.c.
References FIX2INT, 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.
VALUE rb_float_new_in_heap | ( | double | d | ) |
Definition at line 922 of file numeric.c.
References FL_WB_PROTECTED, NEWOBJ_OF, OBJ_FREEZE, rb_cFloat, RGENGC_WB_PROTECTED_FLOAT, and T_FLOAT.
Definition at line 1293 of file numeric.c.
References FIX2LONG, rb_big2dbl(), RB_TYPE_P, RFLOAT_VALUE, round(), T_BIGNUM, T_FIXNUM, and T_FLOAT.
Definition at line 1038 of file numeric.c.
References DBL2NUM, and RFLOAT_VALUE.
Definition at line 3471 of file numeric.c.
References FIXNUM_P, rb_any_to_s(), rb_big2str(), rb_fix2str(), RB_TYPE_P, and T_BIGNUM.
Definition at line 3668 of file numeric.c.
References DBL2NUM, Qnil, rb_int_fdiv_double(), and RB_INTEGER_TYPE_P.
Definition at line 3637 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().
VALUE rb_int_round | ( | VALUE | num, |
int | ndigits, | ||
enum ruby_num_rounding_mode | mode | ||
) |
Definition at line 3033 of file numeric.c.
References FIX2LONG, FIXABLE, FIXNUM_P, FLOAT_OUT_OF_RANGE, LONG2FIX, NIL_P, rb_eRangeError, rb_eTypeError, rb_num2long(), rb_raise(), rb_to_int(), RB_TYPE_P, RFLOAT_VALUE, T_BIGNUM, T_FALSE, T_FIXNUM, T_FLOAT, T_NIL, T_STRING, T_TRUE, and val.
long rb_num2int | ( | VALUE | val | ) |
Definition at line 2947 of file numeric.c.
References rb_num2long().
long rb_num2long | ( | VALUE | val | ) |
Definition at line 2799 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().
short rb_num2short | ( | VALUE | val | ) |
Definition at line 2991 of file numeric.c.
References rb_num2long().
unsigned short rb_num2ushort | ( | VALUE | val | ) |
Definition at line 3009 of file numeric.c.
Referenced by rb_fix2ushort().
Definition at line 473 of file numeric.c.
Referenced by rb_big_divmod(), rb_big_modulo(), rb_big_mul(), and rb_big_remainder().
Definition at line 4309 of file numeric.c.
Referenced by rb_big_and(), rb_big_or(), and rb_big_xor().
Definition at line 488 of file numeric.c.
Referenced by rb_float_gt().
enum ruby_num_rounding_mode rb_num_get_rounding_option | ( | VALUE | opts | ) |
Definition at line 198 of file numeric.c.
References NIL_P, PRIsVALUE, rb_check_string_type(), rb_eArgError, rb_get_kwargs(), rb_intern_const, rb_memcicmp(), rb_raise(), rb_sym2str, RB_TYPE_P, RSTRING_LEN, RSTRING_PTR, RUBY_NUM_ROUND_DEFAULT, RUBY_NUM_ROUND_HALF_DOWN, RUBY_NUM_ROUND_HALF_EVEN, RUBY_NUM_ROUND_HALF_UP, strncasecmp, SYMBOL_P, and T_STRING.
int rb_num_to_uint | ( | VALUE | val, |
unsigned int * | ret | ||
) |
Definition at line 242 of file numeric.c.
References BIGNUM_NEGATIVE_P, FIX2LONG, FIXNUM_P, NULL, NUMERR_NEGATIVE, NUMERR_TOOLARGE, NUMERR_TYPE, rb_absint_size(), rb_big2ulong(), RB_TYPE_P, T_BIGNUM, and val.
Referenced by rb_str_concat().
void rb_num_zerodiv | ( | void | ) |
Definition at line 192 of file numeric.c.
References rb_eZeroDivError, and rb_raise().
Referenced by rb_big_divrem_normal().
double round | ( | double | x | ) |
Definition at line 79 of file numeric.c.
References f.
Referenced by rb_big_pow(), and rb_float_pow().
double ruby_float_mod | ( | double | x, |
double | y | ||
) |
VALUE rb_cFloat |
Definition at line 180 of file numeric.c.
Referenced by rb_float_new_in_heap().
VALUE rb_eZeroDivError |
Definition at line 186 of file numeric.c.
Referenced by rb_num_zerodiv().
const union bytesequence4_or_float rb_infinity = {{0x00, 0x00, 0x80, 0x7f}} |
const union bytesequence4_or_float rb_nan = {{0x00, 0x00, 0xc0, 0x7f}} |