Ruby: math.c File Reference

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

Macros | Functions | Variables
math.c File Reference
`#include "ruby/internal/config.h"`
`#include <errno.h>`
`#include <float.h>`
`#include <math.h>`
`#include "internal.h"`
`#include "internal/bignum.h"`
`#include "internal/complex.h"`
`#include "internal/object.h"`
`#include "internal/vm.h"`

Go to the source code of this file.

## Macros
#define | _USE_MATH_DEFINES 1
#define | RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
#define | Get_Double(x) rb_num_to_dbl(x)
#define | domain_error(msg) rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg)
#define | M_LN2 0.693147180559945309417232121458176568
#define | M_LN10 2.30258509299404568401799145468436421
#define | f_boolcast(x) ((x) ? Qtrue : Qfalse)
#define | exp1(n)
#define | exp2(n)

## Functions
double | cosh (double x)
double | sinh (double x)
double | tanh (double x)
| FUNC_MINIMIZED (static VALUE math_log(int, const VALUE *, VALUE))
VALUE | rb_math_log (int argc, const VALUE *argv)
double | log2 (double x)
| exp2 (atan2)
void | Init_Math (void)

## Variables
VALUE | rb_mMath
VALUE | rb_eMathDomainError

## Macro Definition Documentation

## ◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES 1

Definition at line 15 of file math.c.

## ◆ domain_error

#define domain_error | ( |  | msg | ) | rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg)

Definition at line 41 of file math.c.

## ◆ exp1

#define exp1 | ( |  | n | ) |

Value:
VALUE \
rb_math_##n(VALUE x)\
{\
return math_##n(0, x);\
}
VALUE
unsigned long VALUE
Definition: value.h:38

Definition at line 932 of file math.c.

## ◆ exp2

#define exp2 | ( |  | n | ) |

Value:
VALUE \
rb_math_##n(VALUE x, VALUE y)\
{\
return math_##n(0, x, y);\
}

Definition at line 939 of file math.c.

## ◆ f_boolcast

#define f_boolcast | ( |  | x | ) | ((x) ? Qtrue : Qfalse)

Definition at line 626 of file math.c.

## ◆ Get_Double

#define Get_Double | ( |  | x | ) | rb_num_to_dbl(x)

Definition at line 39 of file math.c.

## ◆ M_LN10

#define M_LN10 2.30258509299404568401799145468436421

Definition at line 434 of file math.c.

## ◆ M_LN2

#define M_LN2 0.693147180559945309417232121458176568

Definition at line 431 of file math.c.

## ◆ RB_BIGNUM_TYPE_P

#define RB_BIGNUM_TYPE_P | ( |  | x | ) | RB_TYPE_P((x), T_BIGNUM)

Definition at line 34 of file math.c.

## Function Documentation

## ◆ cosh()

double cosh | ( | double | x | ) |

Definition at line 237 of file math.c.

Referenced by tanh().

## ◆ exp2()

exp2 | ( | atan2 |  | ) |

Definition at line 946 of file math.c.

References DBL2NUM, M_PI, rb_define_class_under(), rb_define_const(), rb_define_module(), rb_define_module_function, rb_eMathDomainError, rb_eStandardError, and rb_mMath.

## ◆ FUNC_MINIMIZED()

FUNC_MINIMIZED | ( | static VALUE | math_logint, const VALUE *, VALUE | ) |

## ◆ Init_Math()

void Init_Math | ( | void |  | ) |

Definition at line 1039 of file math.c.

References InitVM.

## ◆ log2()

double log2 | ( | double | x | ) |

Definition at line 515 of file math.c.

## ◆ rb_math_log()

VALUE rb_math_log | ( | int | argc,
|  | const VALUE * | argv
| ) |  |

Definition at line 468 of file math.c.

References argc, argv, DBL2NUM, and rb_scan_args().

Referenced by imp1().

## ◆ sinh()

double sinh | ( | double | x | ) |

Definition at line 265 of file math.c.

Referenced by tanh().

## ◆ tanh()

double tanh | ( | double | x | ) |

Definition at line 293 of file math.c.

References cosh(), isinf(), and sinh().

## Variable Documentation

## ◆ rb_eMathDomainError

VALUE rb_eMathDomainError

Definition at line 37 of file math.c.

Referenced by exp2().

## ◆ rb_mMath

VALUE rb_mMath

Definition at line 36 of file math.c.

Referenced by exp2().