Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
|
Arithmetic conversion between C's long
and Ruby's.
More...
#include "ruby/internal/config.h"
#include "ruby/internal/arithmetic/fixnum.h"
#include "ruby/internal/arithmetic/intptr_t.h"
#include "ruby/internal/assume.h"
#include "ruby/internal/attr/artificial.h"
#include "ruby/internal/attr/cold.h"
#include "ruby/internal/attr/const.h"
#include "ruby/internal/attr/constexpr.h"
#include "ruby/internal/attr/noreturn.h"
#include "ruby/internal/cast.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/special_consts.h"
#include "ruby/internal/value.h"
#include "ruby/assert.h"
Go to the source code of this file.
Macros | |
#define | FIX2LONG RB_FIX2LONG |
#define | FIX2ULONG RB_FIX2ULONG |
#define | INT2FIX RB_INT2FIX |
#define | LONG2FIX RB_INT2FIX |
#define | LONG2NUM RB_LONG2NUM |
#define | NUM2LONG RB_NUM2LONG |
#define | NUM2ULONG RB_NUM2ULONG |
#define | RB_FIX2LONG rb_fix2long |
#define | RB_FIX2ULONG rb_fix2ulong |
#define | RB_LONG2FIX RB_INT2FIX |
#define | RB_LONG2NUM rb_long2num_inline |
#define | RB_NUM2LONG rb_num2long_inline |
#define | RB_NUM2ULONG rb_num2ulong_inline |
#define | RB_ULONG2NUM rb_ulong2num_inline |
#define | ULONG2NUM RB_ULONG2NUM |
#define | rb_fix_new RB_INT2FIX |
#define | rb_long2int rb_long2int_inline |
Functions | |
void | rb_out_of_int (SIGNED_VALUE num) |
long | rb_num2long (VALUE num) |
unsigned long | rb_num2ulong (VALUE num) |
Arithmetic conversion between C's long
and Ruby's.
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. __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. int.h
?long
. It seems someone did not understand the difference of int
and long
when they designed those macros. Definition in file long.h.
#define FIX2LONG RB_FIX2LONG |
#define FIX2ULONG RB_FIX2ULONG |
#define LONG2NUM RB_LONG2NUM |
#define NUM2LONG RB_NUM2LONG |
#define NUM2ULONG RB_NUM2ULONG |
#define ULONG2NUM RB_ULONG2NUM |
Definition at line 2894 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(), RFLOAT_VALUE, T_BIGNUM, and T_FLOAT.
Referenced by rb_fix2short(), rb_num2fix(), rb_num2int(), and rb_num2short().
void rb_out_of_int | ( | SIGNED_VALUE | num | ) |
Definition at line 2969 of file numeric.c.
References num, PRIdVALUE, rb_eRangeError, and rb_raise().