Ruby: include/ruby/internal/arithmetic/fixnum.h File Reference

Ruby 3.3.5p100 (2024-09-03 revision ef084cc8f4958c1b6e4ead99136631bef6d8ddba)

Macros
fixnum.h File Reference

Handling of integers formerly known as Fixnums. More...

`#include "ruby/backward/2/limits.h"`

Go to the source code of this file.

## Macros
#define | FIXABLE RB_FIXABLE
| Old name of RB_FIXABLE.
#define | FIXNUM_MAX RUBY_FIXNUM_MAX
| Old name of RUBY_FIXNUM_MAX.
#define | FIXNUM_MIN RUBY_FIXNUM_MIN
| Old name of RUBY_FIXNUM_MIN.
#define | NEGFIXABLE RB_NEGFIXABLE
| Old name of RB_NEGFIXABLE.
#define | POSFIXABLE RB_POSFIXABLE
| Old name of RB_POSFIXABLE.
#define | RB_POSFIXABLE(_)
| Checks if the passed value is in range of fixnum, assuming it is a positive number.
#define | RB_NEGFIXABLE(_)
| Checks if the passed value is in range of fixnum, assuming it is a negative number.
#define | RB_FIXABLE(_)
| Checks if the passed value is in range of fixnum.
#define | RUBY_FIXNUM_MAX (LONG_MAX / 2)
| Maximum possible value that a fixnum can represent.
#define | RUBY_FIXNUM_MIN (LONG_MIN / 2)
| Minimum possible value that a fixnum can represent.

## Detailed Description

Handling of integers formerly known as Fixnums.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `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.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__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.

Definition in file fixnum.h.

## Macro Definition Documentation

## ◆ RB_FIXABLE

#define RB_FIXABLE | ( |  | _ | ) |

Value:
(RB_POSFIXABLE(_) && RB_NEGFIXABLE(_))
RB_POSFIXABLE
#define RB_POSFIXABLE(_)
Checks if the passed value is in range of fixnum, assuming it is a positive number.
Definition fixnum.h:43
RB_NEGFIXABLE
#define RB_NEGFIXABLE(_)
Checks if the passed value is in range of fixnum, assuming it is a negative number.
Definition fixnum.h:49
_
#define _(args)
This was a transition path from K&R to ANSI.
Definition stdarg.h:35

Checks if the passed value is in range of fixnum.

Definition at line 52 of file fixnum.h.

Referenced by RB_INT2FIX(), rb_int2num_inline(), rb_long2num_inline(), and RB_ST2FIX().

## ◆ RB_NEGFIXABLE

#define RB_NEGFIXABLE | ( |  | _ | ) |

Value:
((_) >= RUBY_FIXNUM_MIN)
RUBY_FIXNUM_MIN
#define RUBY_FIXNUM_MIN
Minimum possible value that a fixnum can represent.
Definition fixnum.h:58

Checks if the passed value is in range of fixnum, assuming it is a negative number.

This is an implementation of RB_FIXABLE. Rarely used stand alone.

Definition at line 49 of file fixnum.h.

## ◆ RB_POSFIXABLE

#define RB_POSFIXABLE | ( |  | _ | ) |

Value:
((_) < RUBY_FIXNUM_MAX + 1)
RUBY_FIXNUM_MAX
#define RUBY_FIXNUM_MAX
Maximum possible value that a fixnum can represent.
Definition fixnum.h:55

Checks if the passed value is in range of fixnum, assuming it is a positive number.

Can sometimes be useful for C's unsigned integer types.

Definition at line 43 of file fixnum.h.

Referenced by rb_uint2num_inline(), and rb_ulong2num_inline().

## ◆ RUBY_FIXNUM_MAX

#define RUBY_FIXNUM_MAX (LONG_MAX / 2)

Maximum possible value that a fixnum can represent.

Definition at line 55 of file fixnum.h.

Referenced by RB_ST2FIX().

## ◆ RUBY_FIXNUM_MIN

#define RUBY_FIXNUM_MIN (LONG_MIN / 2)

Minimum possible value that a fixnum can represent.

Definition at line 58 of file fixnum.h.

Referenced by RB_ST2FIX().