Debian Codegraph @

include/ruby/internal/arithmetic/double.h

raw
1 #ifndef RBIMPL_ARITHMETIC_DOUBLE_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_ARITHMETIC_DOUBLE_H
3 /**
4 * @file
5 * @author Ruby developers <[email protected]>
6 * @copyright This file is a part of the programming language Ruby.
7 * Permission is hereby granted, to either redistribute and/or
8 * modify this file, provided that the conditions mentioned in the
9 * file COPYING are met. Consult the file for details.
10 * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
11 * implementation details. Don't take them as canon. They could
12 * rapidly appear then vanish. The name (path) of this header file
13 * is also an implementation detail. Do not expect it to persist
14 * at the place it is now. Developers are free to move it anywhere
15 * anytime at will.
16 * @note To ruby-core: remember that this header can be possibly
17 * recursively included from extension libraries written in C++.
18 * Do not expect for instance `__VA_ARGS__` is always available.
19 * We assume C99 for ruby itself but we don't assume languages of
20 * extension libraries. They could be written in C++98.
21 * @brief Arithmetic conversion between C's `double` and Ruby's.
22 */
23 #include "ruby/internal/attr/pure.h"
24 #include "ruby/internal/dllexport.h"
25 #include "ruby/internal/value.h"
26
27 #define NUM2DBL rb_num2dbl /**< @old{rb_num2dbl} */
28 #define RFLOAT_VALUE rb_float_value /**< @old{rb_float_value} */
29 #define DBL2NUM rb_float_new /**< @old{rb_float_new} */
30
31 RBIMPL_SYMBOL_EXPORT_BEGIN()
32 /**
33 * Converts an instance of ::rb_cNumeric into C's `double`.
34 *
35 * @param[in] num Something numeric.
36 * @exception rb_eTypeError `num` is not a numeric.
37 * @return The passed value converted into C's `double`.
38 */
39 double rb_num2dbl(VALUE num);
40
41 RBIMPL_ATTR_PURE()
42 /**
43 * Extracts its double value from an instance of ::rb_cFloat.
44 *
45 * @param[in] num An instance of ::rb_cFloat.
46 * @pre Must not pass anything other than a Fixnum.
47 * @return The passed value converted into C's `double`.
48 */
49 double rb_float_value(VALUE num);
50
51 /**
52 * Converts a C's `double` into an instance of ::rb_cFloat.
53 *
54 * @param[in] d Arbitrary `double` value.
55 * @return An instance of ::rb_cFloat.
56 */
57 VALUE rb_float_new(double d);
58
59 /**
60 * Identical to rb_float_new(), except it does not generate Flonums.
61 *
62 * @param[in] d Arbitrary `double` value.
63 * @return An instance of ::rb_cFloat.
64 *
65 * @internal
66 *
67 * @shyouhei has no idea why it is here.
68 */
69 VALUE rb_float_new_in_heap(double d);
70 RBIMPL_SYMBOL_EXPORT_END()
71
72 #endif /* RBIMPL_ARITHMETIC_DOUBLE_H */