v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
ieee754.h
Go to the documentation of this file.
1// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_BASE_IEEE754_H_
6#define V8_BASE_IEEE754_H_
7
9
10#if defined(V8_USE_LIBM_TRIG_FUNCTIONS)
11#include "third_party/glibc/src/sysdeps/ieee754/dbl-64/trig.h" // nogncheck
12#endif
13
14namespace v8 {
15namespace base {
16namespace ieee754 {
17
18// Returns the arc cosine of |x|; that is the value whose cosine is |x|.
19V8_BASE_EXPORT double acos(double x);
20
21// Returns the inverse hyperbolic cosine of |x|; that is the value whose
22// hyperbolic cosine is |x|.
23V8_BASE_EXPORT double acosh(double x);
24
25// Returns the arc sine of |x|; that is the value whose sine is |x|.
26V8_BASE_EXPORT double asin(double x);
27
28// Returns the inverse hyperbolic sine of |x|; that is the value whose
29// hyperbolic sine is |x|.
30V8_BASE_EXPORT double asinh(double x);
31
32// Returns the principal value of the arc tangent of |x|; that is the value
33// whose tangent is |x|.
34V8_BASE_EXPORT double atan(double x);
35
36// Returns the principal value of the arc tangent of |y/x|, using the signs of
37// the two arguments to determine the quadrant of the result.
38V8_BASE_EXPORT double atan2(double y, double x);
39
40#if defined(V8_USE_LIBM_TRIG_FUNCTIONS)
41// To ensure there aren't problems with libm's sin/cos, both implementations
42// are shipped. The plan is to transition to libm once we ensure there are no
43// compatibility or performance issues.
44V8_BASE_EXPORT double fdlibm_sin(double x);
45V8_BASE_EXPORT double fdlibm_cos(double x);
46
47#if !defined(BUILDING_V8_BASE_SHARED) && !defined(USING_V8_BASE_SHARED)
48inline double libm_sin(double x) { return glibc_sin(x); }
49inline double libm_cos(double x) { return glibc_cos(x); }
50#else
51V8_BASE_EXPORT double libm_sin(double x);
52V8_BASE_EXPORT double libm_cos(double x);
53#endif
54#else
55V8_BASE_EXPORT double cos(double x);
56V8_BASE_EXPORT double sin(double x);
57#endif
58
59// Returns the base-e exponential of |x|.
60V8_BASE_EXPORT double exp(double x);
61
62V8_BASE_EXPORT double atanh(double x);
63
64// Returns the natural logarithm of |x|.
65V8_BASE_EXPORT double log(double x);
66
67// Returns a value equivalent to |log(1+x)|, but computed in a way that is
68// accurate even if the value of |x| is near zero.
69V8_BASE_EXPORT double log1p(double x);
70
71// Returns the base 2 logarithm of |x|.
72V8_BASE_EXPORT double log2(double x);
73
74// Returns the base 10 logarithm of |x|.
75V8_BASE_EXPORT double log10(double x);
76
77// Returns the cube root of |x|.
78V8_BASE_EXPORT double cbrt(double x);
79
80// Returns exp(x)-1, the exponential of |x| minus 1.
81V8_BASE_EXPORT double expm1(double x);
82
83namespace legacy {
84
85// This function should not be used directly. Instead, use
86// v8::internal::math::pow.
87
88// Returns |x| to the power of |y|.
89// The result of base ** exponent when base is 1 or -1 and exponent is
90// +Infinity or -Infinity differs from IEEE 754-2008. The first edition
91// of ECMAScript specified a result of NaN for this operation, whereas
92// later versions of IEEE 754-2008 specified 1. The historical ECMAScript
93// behaviour is preserved for compatibility reasons.
94V8_BASE_EXPORT double pow(double x, double y);
95
96} // namespace legacy
97
98// Returns the tangent of |x|, where |x| is given in radians.
99V8_BASE_EXPORT double tan(double x);
100
101// Returns the hyperbolic cosine of |x|, where |x| is given radians.
102V8_BASE_EXPORT double cosh(double x);
103
104// Returns the hyperbolic sine of |x|, where |x| is given radians.
105V8_BASE_EXPORT double sinh(double x);
106
107// Returns the hyperbolic tangent of |x|, where |x| is given radians.
108V8_BASE_EXPORT double tanh(double x);
109
110} // namespace ieee754
111} // namespace base
112} // namespace v8
113
114#endif // V8_BASE_IEEE754_H_
#define V8_BASE_EXPORT
Definition base-export.h:26
int y
int x
double pow(double x, double y)
Definition ieee754.cc:2646
double atanh(double x)
Definition ieee754.cc:1557
double tan(double x)
Definition ieee754.cc:2510
double log(double x)
Definition ieee754.cc:1638
double log2(double x)
Definition ieee754.cc:1973
double sinh(double x)
Definition ieee754.cc:2930
double atan2(double y, double x)
Definition ieee754.cc:1228
double cosh(double x)
Definition ieee754.cc:2554
double acosh(double x)
Definition ieee754.cc:936
double sin(double x)
Definition ieee754.cc:2450
double exp(double x)
Definition ieee754.cc:1447
double log10(double x)
Definition ieee754.cc:2079
double cos(double x)
Definition ieee754.cc:1354
double acos(double x)
Definition ieee754.cc:862
double log1p(double x)
Definition ieee754.cc:1783
double expm1(double x)
Definition ieee754.cc:2213
double tanh(double x)
Definition ieee754.cc:2986
double cbrt(double x)
Definition ieee754.cc:2333
double asinh(double x)
Definition ieee754.cc:1067
double asin(double x)
Definition ieee754.cc:991
double atan(double x)
Definition ieee754.cc:1116