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

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

Macros | Functions
double.h File Reference

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

`#include "ruby/internal/attr/pure.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`

Go to the source code of this file.

## Macros
#define | NUM2DBL rb_num2dbl
| Old name of rb_num2dbl.
#define | RFLOAT_VALUE rb_float_value
| Old name of rb_float_value.
#define | DBL2NUM rb_float_new
| Old name of rb_float_new.

## Functions
double | rb_num2dbl (VALUE num)
| Converts an instance of rb_cNumeric into C's `double`.
double | rb_float_value (VALUE num)
| Extracts its double value from an instance of rb_cFloat.
VALUE | rb_float_new (double d)
| Converts a C's `double` into an instance of rb_cFloat.
VALUE | rb_float_new_in_heap (double d)
| Identical to rb_float_new(), except it does not generate Flonums.

## Detailed Description

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

## Function Documentation

## ◆ rb_float_new()

VALUE rb_float_new | ( | double | d | ) |

Converts a C's `double` into an instance of rb_cFloat.

Parameters

  [in] | d | Arbitrary `double` value.

Returns
  An instance of rb_cFloat.

Definition at line 6425 of file numeric.c.

## ◆ rb_float_new_in_heap()

VALUE rb_float_new_in_heap | ( | double | d | ) |

Identical to rb_float_new(), except it does not generate Flonums.

Parameters

  [in] | d | Arbitrary `double` value.

Returns
  An instance of rb_cFloat.

Definition at line 1014 of file numeric.c.

## ◆ rb_float_value()

double rb_float_value | ( | VALUE | num | ) |

Extracts its double value from an instance of rb_cFloat.

Parameters

  [in] | num | An instance of rb_cFloat.

Precondition
  Must not pass anything other than a Fixnum.

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

Definition at line 6418 of file numeric.c.