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

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Functions
short.h File Reference

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

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

Go to the source code of this file.

## Macros
#define | RB_NUM2SHORT rb_num2short_inline
#define | RB_NUM2USHORT rb_num2ushort
#define | NUM2SHORT RB_NUM2SHORT
#define | NUM2USHORT RB_NUM2USHORT
#define | USHORT2NUM RB_INT2FIX
#define | RB_FIX2SHORT rb_fix2short
#define | FIX2SHORT RB_FIX2SHORT

## Functions
short | rb_num2short (VALUE)
unsigned short | rb_num2ushort (VALUE)
short | rb_fix2short (VALUE)
unsigned short | rb_fix2ushort (VALUE)

## Detailed Description

Arithmetic conversion between C's `short` 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.

Shyouhei wonders: why there is no SHORT2NUM, given there are both USHORT2NUM and CHR2FIX?

Definition in file short.h.

## Macro Definition Documentation

## ◆ FIX2SHORT

#define FIX2SHORT RB_FIX2SHORT

Definition at line 36 of file short.h.

## ◆ NUM2SHORT

#define NUM2SHORT RB_NUM2SHORT

Definition at line 32 of file short.h.

## ◆ NUM2USHORT

#define NUM2USHORT RB_NUM2USHORT

Definition at line 33 of file short.h.

## ◆ RB_FIX2SHORT

#define RB_FIX2SHORT rb_fix2short

Definition at line 35 of file short.h.

## ◆ RB_NUM2SHORT

#define RB_NUM2SHORT rb_num2short_inline

Definition at line 30 of file short.h.

## ◆ RB_NUM2USHORT

#define RB_NUM2USHORT rb_num2ushort

Definition at line 31 of file short.h.

## ◆ USHORT2NUM

#define USHORT2NUM RB_INT2FIX

Definition at line 34 of file short.h.

## Function Documentation

## ◆ rb_fix2short()

short rb_fix2short | ( | VALUE | val | ) |

Definition at line 3107 of file numeric.c.

References FIX2LONG, FIXNUM_P, num, and rb_num2long().

## ◆ rb_fix2ushort()

unsigned short rb_fix2ushort | ( | VALUE | val | ) |

Definition at line 3126 of file numeric.c.

References FIX2ULONG, FIXNUM_P, num, and rb_num2ushort().

## ◆ rb_num2short()

short rb_num2short | ( | VALUE | val | ) |

Definition at line 3098 of file numeric.c.

References num, and rb_num2long().

## ◆ rb_num2ushort()

unsigned short rb_num2ushort | ( | VALUE | val | ) |

Definition at line 3116 of file numeric.c.

References num.

Referenced by rb_fix2ushort().