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

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

Macros | Functions
long_long.h File Reference

Arithmetic conversion between C's `long long` and Ruby's. More...

`#include "ruby/internal/value.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/special_consts.h"`
`#include "ruby/backward/2/long_long.h"`

Go to the source code of this file.

## Macros
#define | RB_LL2NUM rb_ll2num_inline
| Just another name of rb_ll2num_inline.
#define | RB_ULL2NUM rb_ull2num_inline
| Just another name of rb_ull2num_inline.
#define | LL2NUM RB_LL2NUM
| Old name of RB_LL2NUM.
#define | ULL2NUM RB_ULL2NUM
| Old name of RB_ULL2NUM.
#define | RB_NUM2LL rb_num2ll_inline
| Just another name of rb_num2ll_inline.
#define | RB_NUM2ULL rb_num2ull_inline
| Just another name of rb_num2ull_inline.
#define | NUM2LL RB_NUM2LL
| Old name of RB_NUM2LL.
#define | NUM2ULL RB_NUM2ULL
| Old name of RB_NUM2ULL.

## Functions
VALUE | rb_ll2inum (LONG_LONG num)
| Converts a C's `long long` into an instance of rb_cInteger.
VALUE | rb_ull2inum (unsigned LONG_LONG num)
| Converts a C's `unsigned long long` into an instance of rb_cInteger.
LONG_LONG | rb_num2ll (VALUE num)
| Converts an instance of rb_cNumeric into C's `long long`.
unsigned LONG_LONG | rb_num2ull (VALUE num)
| Converts an instance of rb_cNumeric into C's `unsigned long long`.
static VALUE | rb_ll2num_inline (LONG_LONG n)
| Converts a C's `long long` into an instance of rb_cInteger.
static VALUE | rb_ull2num_inline (unsigned LONG_LONG n)
| Converts a C's `unsigned long long` into an instance of rb_cInteger.
static LONG_LONG | rb_num2ll_inline (VALUE x)
| Converts an instance of rb_cNumeric into C's `long long`.
static unsigned LONG_LONG | rb_num2ull_inline (VALUE x)
| Converts an instance of rb_cNumeric into C's `unsigned long long`.

## Detailed Description

Arithmetic conversion between C's `long long` and Ruby's.

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 long_long.h.

## Macro Definition Documentation

## ◆ RB_LL2NUM

#define RB_LL2NUM rb_ll2num_inline

Just another name of rb_ll2num_inline.

Definition at line 28 of file long_long.h.

## ◆ RB_NUM2LL

#define RB_NUM2LL rb_num2ll_inline

Just another name of rb_num2ll_inline.

Definition at line 32 of file long_long.h.

## ◆ RB_NUM2ULL

#define RB_NUM2ULL rb_num2ull_inline

Just another name of rb_num2ull_inline.

Definition at line 33 of file long_long.h.

## ◆ RB_ULL2NUM

#define RB_ULL2NUM rb_ull2num_inline

Just another name of rb_ull2num_inline.

Definition at line 29 of file long_long.h.

## Function Documentation

## ◆ rb_ll2inum()

VALUE rb_ll2inum | ( | LONG_LONG | num | ) |

Converts a C's `long long` into an instance of rb_cInteger.

Parameters

  [in] | num | Arbitrary `long long` value.

Returns
  An instance of rb_cInteger.

Referenced by rb_ll2num_inline().

## ◆ rb_ll2num_inline()

static VALUE rb_ll2num_inline | ( | LONG_LONG | n | ) |
| inlinestatic

Converts a C's `long long` into an instance of rb_cInteger.

Parameters

  [in] | n | Arbitrary `long long` value.

Returns
  An instance of rb_cInteger

Definition at line 82 of file long_long.h.

## ◆ rb_num2ll()

LONG_LONG rb_num2ll | ( | VALUE | num | ) |

Converts an instance of rb_cNumeric into C's `long long`.

Parameters

  [in] | num | Something numeric.

Exceptions

  rb_eTypeError | `num` is not a numeric.
  rb_eRangeError | `num` is out of range of `long long`.

Returns
  The passed value converted into C's `long long`.

Referenced by rb_num2ll_inline().

## ◆ rb_num2ll_inline()

static LONG_LONG rb_num2ll_inline | ( | VALUE | x | ) |
| inlinestatic

Converts an instance of rb_cNumeric into C's `long long`.

Parameters

  [in] | x | Something numeric.

Exceptions

  rb_eTypeError | `x` is not a numeric.
  rb_eRangeError | `x` is out of range of `long long`.

Returns
  The passed value converted into C's `long long`.

Definition at line 110 of file long_long.h.

## ◆ rb_num2ull()

unsigned LONG_LONG rb_num2ull | ( | VALUE | num | ) |

Converts an instance of rb_cNumeric into C's `unsigned long long`.

Parameters

  [in] | num | Something numeric.

Exceptions

  rb_eTypeError | `num` is not a numeric.
  rb_eRangeError | `num` is out of range of `unsigned long long`.

Returns
  The passed value converted into C's `unsigned long long`.

Referenced by rb_num2ull_inline().

## ◆ rb_num2ull_inline()

static unsigned LONG_LONG rb_num2ull_inline | ( | VALUE | x | ) |
| inlinestatic

Converts an instance of rb_cNumeric into C's `unsigned long long`.

Parameters

  [in] | x | Something numeric.

Exceptions

  rb_eTypeError | `x` is not a numeric.
  rb_eRangeError | `x` is out of range of `unsigned long long`.

Returns
  The passed value converted into C's `unsigned long long`.

Definition at line 127 of file long_long.h.

## ◆ rb_ull2inum()

VALUE rb_ull2inum | ( | unsigned LONG_LONG | num | ) |

Converts a C's `unsigned long long` into an instance of rb_cInteger.

Parameters

  [in] | num | Arbitrary `unsigned long long` value.

Returns
  An instance of rb_cInteger.

Referenced by rb_ull2num_inline().

## ◆ rb_ull2num_inline()

static VALUE rb_ull2num_inline | ( | unsigned LONG_LONG | n | ) |
| inlinestatic

Converts a C's `unsigned long long` into an instance of rb_cInteger.

Parameters

  [in] | n | Arbitrary `unsigned long long` value.

Returns
  An instance of rb_cInteger

Definition at line 95 of file long_long.h.