|
Ruby 3.4.5p51 (2025-07-16 revision 20cda200d3ce092571d0b5d342dadca69636cb0f)
|
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.
Functions | |
| void | rb_out_of_int (SIGNED_VALUE num) |
| This is an utility function to raise an rb_eRangeError. | |
| long | rb_num2long (VALUE num) |
| Converts an instance of rb_cNumeric into C's long. | |
| unsigned long | rb_num2ulong (VALUE num) |
| Converts an instance of rb_cNumeric into C's unsigned long. | |
| static VALUE | RB_INT2FIX (long i) |
| Converts a C's long into an instance of rb_cInteger. | |
| static int | rb_long2int_inline (long n) |
| Checks if int can hold the given integer. | |
| static long | rb_fix2long (VALUE x) |
| Converts a Fixnum into C's long. | |
| static unsigned long | rb_fix2ulong (VALUE x) |
| Converts a Fixnum into C's unsigned long. | |
| static long | rb_num2long_inline (VALUE x) |
| Converts an instance of rb_cNumeric into C's long. | |
| static unsigned long | rb_num2ulong_inline (VALUE x) |
| Converts an instance of rb_cNumeric into C's unsigned long. | |
| static VALUE | rb_long2num_inline (long v) |
| Converts a C's long into an instance of rb_cInteger. | |
| static VALUE | rb_ulong2num_inline (unsigned long v) |
| Converts a C's unsigned long into an instance of rb_cInteger. | |
Arithmetic conversion between C's long and Ruby's.
Definition in file long.h.
| #define RB_FIX2LONG rb_fix2long |
Just another name of rb_fix2long.
Definition at line 53 of file long.h.
Referenced by RB_FIX2INT(), rb_num2ll_inline(), rb_num2long_inline(), and rb_num2ull_inline().
| #define RB_FIX2ULONG rb_fix2ulong |
Just another name of rb_fix2ulong.
Definition at line 54 of file long.h.
Referenced by RB_FIX2UINT(), rb_fix2uint(), and rb_num2ulong_inline().
| #define rb_fix_new RB_INT2FIX |
Just another name of RB_INT2FIX.
| #define RB_LONG2FIX RB_INT2FIX |
Just another name of RB_INT2FIX.
Definition at line 55 of file long.h.
Referenced by rb_long2num_inline(), RB_ST2FIX(), rb_uint2num_inline(), and rb_ulong2num_inline().
| #define rb_long2int rb_long2int_inline |
Just another name of rb_long2int_inline.
Definition at line 62 of file long.h.
Referenced by RARRAY_LENINT(), rb_profile_frame_full_label(), rb_str_format(), rb_struct_new(), and RSTRING_LENINT().
| #define RB_LONG2NUM rb_long2num_inline |
Just another name of rb_long2num_inline.
| #define RB_NUM2LONG rb_num2long_inline |
Just another name of rb_num2long_inline.
Definition at line 57 of file long.h.
Referenced by rb_num2int_inline(), and RSTRUCT_LEN().
| #define RB_NUM2ULONG rb_num2ulong_inline |
Just another name of rb_num2ulong_inline.
Definition at line 58 of file long.h.
Referenced by RB_NUM2UINT().
| #define RB_ULONG2NUM rb_ulong2num_inline |
Just another name of rb_ulong2num_inline.
|
inlinestatic |
Converts a Fixnum into C's long.
| [in] | x | Some Fixnum. |
Definition at line 231 of file long.h.
Referenced by rb_fix2long(), and rb_fix2ulong().
|
inlinestatic |
Converts a Fixnum into C's unsigned long.
| [in] | x | Some Fixnum. |
Definition at line 252 of file long.h.
Referenced by rb_fix2ulong().
|
inlinestatic |
Converts a C's long into an instance of rb_cInteger.
| [in] | i | Arbitrary long value. |
Definition at line 111 of file long.h.
Referenced by RB_CHR2FIX(), RB_INT2FIX(), and rb_int2num_inline().
|
inlinestatic |
|
inlinestatic |
Converts a C's long into an instance of rb_cInteger.
| [in] | v | Arbitrary long value. |
| long rb_num2long | ( | VALUE | num | ) |
Converts an instance of rb_cNumeric into C's long.
| [in] | num | Something numeric. |
| rb_eTypeError | `num` is not a numeric. |
| rb_eRangeError | `num` is out of range of `long`. |
Definition at line 3196 of file numeric.c.
Referenced by rb_fix2short(), rb_num2fix(), rb_num2int(), rb_num2long(), rb_num2long_inline(), and rb_num2short().
|
inlinestatic |
Converts an instance of rb_cNumeric into C's long.
| [in] | x | Something numeric. |
| rb_eTypeError | `x` is not a numeric. |
| rb_eRangeError | `x` is out of range of `long`. |
| unsigned long rb_num2ulong | ( | VALUE | num | ) |
Converts an instance of rb_cNumeric into C's unsigned long.
| [in] | num | Something numeric. |
| rb_eTypeError | `num` is not a numeric. |
| rb_eRangeError | `num` is out of range of `unsigned long`. |
Definition at line 3265 of file numeric.c.
Referenced by rb_num2uint(), rb_num2ulong(), and rb_num2ulong_inline().
|
inlinestatic |
Converts an instance of rb_cNumeric into C's unsigned long.
| [in] | x | Something numeric. |
| rb_eTypeError | `x` is not a numeric. |
| rb_eRangeError | `x` is out of range of `unsigned long`. |
| void rb_out_of_int | ( | SIGNED_VALUE | num | ) |
This is an utility function to raise an rb_eRangeError.
| [in] | num | A signed value about to overflow. |
| rb_eRangeError | `num` is out of range of `int`. |
Definition at line 3271 of file numeric.c.
Referenced by rb_long2int_inline(), and rb_out_of_int().
|
inlinestatic |
Converts a C's unsigned long into an instance of rb_cInteger.
| [in] | v | Arbitrary unsigned long value. |