The VCSSL Math library is a standard library providing mathematical functions.
Specifically, it includes exponential functions, logarithmic functions, square roots and n-th roots, factorials, trigonometric functions, inverse trigonometric functions, hyperbolic functions, inverse hyperbolic functions, and absolute-value and max/min functions.
This library provides mathematical functions in both 64-bit float precision and arbitrary precision. The former is handled as the float type, and the latter as the varfloat type.
In VCSSL, the float type is not distinguished from the double type. Both have the precision defined by the implementation, and in the current official implementation they are IEEE754 64-bit floats.
As for the varfloat type, the current official implementation does not use a unified standard specification.Instead, it adopts a proprietary decimal arbitrary-precision specification. Rounding is performed by truncation in decimal arithmetic.
The detailed specification of the varfloat type depends on the implementation, and may be changed to some unified standard in the future.
For the float (double) implementations of mathematical functions, built-in implementation features are used, and they are handled at runtime as a kind of special arithmetic instruction.
Many of the float implementations of mathematical functions provided by the Math library are function macros wrapping such special arithmetic instructions.
Therefore, they have no function-call overhead and generally provide good performance.
In contrast, the varfloat (arbitrary-precision) implementations of mathematical functions are implemented in VCSSL code.
Specifically, the algorithms for obtaining values are all implemented in VCSSL using the varfloat type, by methods such as Maclaurin expansion, Taylor expansion, Newton's method, and the Gauss-Legendre algorithm.
For this reason, the execution speed is generally in the slow category. This is due to factors such as the implementation being written in a scripting language, and the varfloat type itself being slow to operate on.
As a concrete example, the following code calculates sin(1) with 1000 significant digits. In this calculation, the sin function takes just under one second to execute.
In the varfloat implementations of mathematical functions, many depend on convergence algorithms, so some accumulated error may appear in the trailing digits.
Anticipating this, the functions internally calculate using a somewhat larger number of digits, varying by function, and truncate the extra digits when returning the value.
However, this is only an auxiliary measure and does not guarantee that digits affected by accumulated error are always eliminated for every possible number of significant digits and every argument.
Depending on the function, validation of accumulated error is generally performed assuming uses of a few dozen significant digits and arguments within ordinary ranges.
For uses requiring thousands to tens of thousands of digits, or for arguments near singular points, accumulated error generally becomes larger and may not fit within the truncated extra digits, so it can also appear in the trailing digits of the returned value.
Therefore, for such uses, please also use a sufficiently large number of significant digits on the caller side while taking accumulated error into account, and take measures such as truncating extra digits.
- None -
| Name | PI |
| Declaration | const float PI |
| Description | The value of pi in float precision. To obtain a varfloat value in arbitrary precision, use pi(). |
| Name | E |
| Declaration | const float E |
| Description | The value of Euler's number, the base of natural logarithms, in float precision. To obtain a varfloat value in arbitrary precision, calculate it with exp( 1.0vf ). |
| Name | nan |
| Declaration | macro nan( float arg ) |
| Description | Determines whether a float value is NaN. |
| Parameters | (float type) arg : The value to be checked. |
| Return | Returns true if it is NaN, or false otherwise. |
| Example |
float x = 0.0/0.0; bool isNaN = nan(x); print("isNaN=" + isNaN); |
| Name | inf |
| Declaration | macro inf( float arg ) |
| Description | Determines whether a float value is Inf. |
| Parameters | (float type) arg : The value to be checked. |
| Return | Returns true if it is Inf, or false otherwise. |
| Example |
float x = 1.0/0.0; bool isInf = inf(x); print("isInf=" + isInf); |
| Name | and |
| Declaration | macro and( int number1, int number2 ) |
| Description | Calculates the bitwise AND operation on int values. |
| Parameters |
(int type) number1 : A value to be operated on. (int type) number2 : A value to be operated on. |
| Return | The calculated value. |
| Example |
int a = 0b01010101; int b = 0b11110000; int c = and(a, b); print( bin(c) ); // 0b1010000 |
| Name | or |
| Declaration | macro or( int number1, int number2 ) |
| Description | Calculates the bitwise OR operation on int values. |
| Parameters |
(int type) number1 : A value to be operated on. (int type) number2 : A value to be operated on. |
| Return | The calculated value. |
| Example |
int a = 0b01010101; int b = 0b11110000; int c = or(a, b); print( bin(c) ); // 0b11110101 |
| Name | xor |
| Declaration | macro xor( int number1, int number2 ) |
| Description | Calculates the bitwise XOR operation on int values. |
| Parameters |
(int type) number1 : A value to be operated on. (int type) number2 : A value to be operated on. |
| Return | The calculated value. |
| Example |
int a = 0b01010101; int b = 0b11110000; int c = xor(a, b); print( bin(c) ); // 0b10100101 |
| Name | random |
| Declaration | macro random() |
| Description | Returns a value greater than or equal to 0.0 and less than 1.0. Note that the documentation before VCSSL 3.0.20 stated that it "returns a random value from 0.0 to 1.0," but that expression was ambiguous, and in practice a value exactly equal to 1.0 is never returned. |
| Return | The random value. |
| Example |
float v = random(); print(v); // 0.367283... (random) |
| Name | rand |
| Declaration | macro rand() |
| Description | Equivalent to random. The use of random is currently recommended instead. Because the name of this function can cause confusion with integer random numbers, its use is no longer recommended. In the future, changing the type of this function may be considered. |
| Return | The random value. |
| Name | pi |
| Declaration | varfloat pi() |
| Description |
Calculates the value of pi. Internally, it is calculated by the Gauss-Legendre algorithm using 1.1 times the original number of digits. A high-precision value of pi is required when calculating periodic functions or simulations with periodic boundaries, such as rotational systems and mapping systems, in order to obtain remainders of arguments or coordinates modulo pi.In fact, the Math library itself uses it for calculations such as varfloat trigonometric functions. |
| Return | (varfloat type) The value of pi. |
| Example |
digit(100); varfloat pi = pi(); print(pi); // 3.14... |
| Name | exp |
| Declaration | macro exp( float arg ) |
| Description | Calculates the exponential function with Euler's number as the base. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
float e = exp(1.0); print(e); // 2.71... |
| Name | exp |
| Declaration | varfloat exp( varfloat arg ) |
| Description |
Calculates the exponential function with Euler's number as the base. Internally, it is calculated by Maclaurin expansion using 1.34 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using the original number of digits plus 4.This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat e = exp(1.0vf); print(e); // 2.71... |
| Name | pow |
| Declaration | macro pow( float arg1, float arg2 ) |
| Description | Calculates a power. |
| Parameters |
(float type) arg1 : The base. (float type) arg2 : The exponent. |
| Return | The calculated value. |
| Example |
float f = pow(1.2, 3.4); print(f); // 1.8587... |
| Name | pow |
| Declaration | varfloat pow( varfloat arg1, varint arg2 ) |
| Description |
Calculates a power whose exponent is an integer. Internally, it is calculated by repeated multiplication using 2.1 times the number of digits given by "the original number of digits plus the absolute value of the order of the exponent (arg2)."However, when the number of digits is 10 or less, it is calculated using the original number of digits plus 4.This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters |
(varfloat type) arg1 : The base. (varint type) arg2 : The exponent. |
| Return | (varfloat type) The calculated value. |
| Name | pow |
| Declaration | varfloat pow( varfloat arg1, varfloat arg2 ) |
| Description |
Calculates a power whose exponent is a floating-point number, that is, a real number. Internally, it is calculated using 1.2 times the number of digits given by "the original number of digits plus the absolute value of the order of the exponent (arg2)," by either Maclaurin expansion or a combination of exponential and logarithmic functions.However, when the number of digits is 10 or less, it is calculated using the original number of digits plus 4.This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters |
(varfloat type) arg1 : The base. (varfloat type) arg2 : The exponent. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat v = pow(1.2vf, 3.4vf); print(v); // 1.8587... |
| Name | pow |
| Declaration | varfloat pow( varint arg1, varfloat arg2 ) |
| Description |
Calculates a power. Internally, arg1 is cast to varfloat and then pow( varfloat, varfloat ) is used. |
| Parameters |
(varint type) arg1 : The base. (varfloat type) arg2 : The exponent. |
| Return | (varfloat type) The calculated value. |
| Name | ln |
| Declaration | macro ln( float arg ) |
| Description | Calculates the natural logarithm. It is the same as log. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
float f = ln(10.0); print(f); // 2.302585... |
| Name | ln |
| Declaration | macro ln( varfloat arg ) |
| Description |
Calculates the natural logarithm. It is the same as log. Internally, log(varfloat) is used as is. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
digit(50); varfloat v = ln(10.0vf); print(v); // 2.302585... |
| Name | log |
| Declaration | macro log( float arg ) |
| Description | Calculates the natural logarithm. It is the same as ln. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
float f = log(10.0); print(f); // 2.302585... |
| Name | log |
| Declaration | varfloat log( varfloat arg ) |
| Description |
Calculates the natural logarithm. It is the same as ln. Internally, it is calculated using 1.34 times the original number of digits, by Newton's method for arguments greater than or equal to 1, and by Taylor expansion for arguments less than or equal to 1.However, when the number of digits is 10 or less, it is calculated using the original number of digits plus 4.This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat v = log(10.0vf); print(v); // 2.302585... |
| Name | log10 |
| Declaration | macro log10( float arg ) |
| Description | Calculates the common logarithm. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
float f = log(10.0); print(f); // 1.0 |
| Name | log10 |
| Declaration | varfloat log10( varfloat arg ) |
| Description |
Calculates the common logarithm. Internally, it is calculated by "log10(x) = ln(x) / ln(10)" using 2.2 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using the original number of digits plus 4. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat v = log10(10.0vf); print(v); |
| Name | sqrt |
| Declaration | macro sqrt( float arg ) |
| Description | Calculates the square root. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
float f = sqrt(2.0); print(f); // 1.4142... |
| Name | sqrt |
| Declaration | varfloat sqrt( varfloat arg ) |
| Description |
Calculates the square root. Internally, it is calculated by Newton's method using 1.34 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using the original number of digits plus 4. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat v = sqrt(2.0vf); print(v); // 1.4142... |
| Name | root |
| Declaration | macro root( float arg, int rootPower ) |
| Description | Calculates the n-th root. |
| Parameters |
(float type) arg : The value to be calculated. (int type) rootPower : The n in the n-th root. |
| Return | The calculated value. |
| Example |
float f = root(2.0, 3); print(f); // 1.259921... |
| Name | root |
| Declaration | varfloat root( varfloat arg, varint p ) |
| Description |
Calculates the n-th root. Internally, it is calculated by Newton's method using 1.34 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using the original number of digits plus 4. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters |
(varfloat type) arg : The value to be calculated. (varint type) p : The n in the n-th root. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat v = root(2.0vf,3v); print(v); // 1.259921... |
| Name | root |
| Declaration | varfloat root( varfloat arg, varfloat vfp ) |
| Description |
Calculates the n-th root. Internally, it is calculated by Newton's method using 1.34 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using the original number of digits plus 4. This extra number of digits may be changed in the future, probably in the direction of higher precision.Note that the second argument of this function is always regarded as an integer.This function is supported only for convenience in modes such as calculator software, where numeric literals are regarded as floating-point numbers.Since there is no particular advantage to using it in ordinary situations, please use root( varfloat, varint ). |
| Parameters |
(varfloat type) arg : The value to be calculated. (varfloat type) vfp : The n in the n-th root. |
| Return | (varfloat type) The calculated value. |
| Name | abs |
| Declaration | macro abs( float arg ) |
| Description | Calculates the absolute value. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
float f = abs(-1.2); print(f); // 1.2 |
| Name | abs |
| Declaration | macro abs( int arg ) |
| Description | Calculates the absolute value. |
| Parameters | (int type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
int i = abs(-123); print(i); // 123 |
| Name | abs |
| Declaration | varfloat abs( varfloat arg ) |
| Description | Calculates the absolute value. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat v = abs(-1.2vf); print(v); // 1.2 |
| Name | abs |
| Declaration | varint abs( varint arg ) |
| Description | Calculates the absolute value. |
| Parameters | (varint type) arg : The value to be calculated. |
| Return | (varint type) The calculated value. |
| Example |
digit(50); varint v = abs(-123v); print(v); // 123 |
| Name | max |
| Declaration | macro max( float arg1, float arg2 ) |
| Description | Returns the larger of the two arguments. |
| Parameters |
(float type) arg1 : A value to be calculated. (float type) arg2 : A value to be calculated. |
| Return | The calculated value. |
| Name | max |
| Declaration | macro max( int arg1, int arg2 ) |
| Description | Returns the larger of the two arguments. |
| Parameters |
(int type) arg1 : A value to be calculated. (int type) arg2 : A value to be calculated. |
| Return | The calculated value. |
| Name | max |
| Declaration | varfloat max( varfloat arg1, varfloat arg2 ) |
| Description | Returns the larger of the two arguments. |
| Parameters |
(varfloat type) arg1 : A value to be calculated. (varfloat type) arg2 : A value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | max |
| Declaration | varint max( varint arg1, varint arg2 ) |
| Description | Returns the larger of the two arguments. |
| Parameters |
(varint type) arg1 : A value to be calculated. (varint type) arg2 : A value to be calculated. |
| Return | (varint type) The calculated value. |
| Name | min |
| Declaration | macro min( float arg1, float arg2 ) |
| Description | Returns the smaller of the two arguments. |
| Parameters |
(float type) arg1 : A value to be calculated. (float type) arg2 : A value to be calculated. |
| Return | The calculated value. |
| Name | min |
| Declaration | macro min( int arg1, int arg2 ) |
| Description | Returns the smaller of the two arguments. |
| Parameters |
(int type) arg1 : A value to be calculated. (int type) arg2 : A value to be calculated. |
| Return | The calculated value. |
| Name | min |
| Declaration | varfloat min( varfloat arg1, varfloat arg2 ) |
| Description | Returns the smaller of the two arguments. |
| Parameters |
(varfloat type) arg1 : A value to be calculated. (varfloat type) arg2 : A value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | min |
| Declaration | varint min( varint arg1, varint arg2 ) |
| Description | Returns the smaller of the two arguments. |
| Parameters |
(varint type) arg1 : A value to be calculated. (varint type) arg2 : A value to be calculated. |
| Return | (varint type) The calculated value. |
| Name | fac |
| Declaration | float fac( float arg ) |
| Description | Calculates the factorial. Although both the argument and the return value of this function are float, the calculation is performed after internally rounding to a nearby int. The conversion may affect the precision because of rounding error. If strict exactness is required, use the version taking an int argument. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | (float type) The calculated value. |
| Name | fac |
| Declaration | macro fac( int arg ) |
| Description | Calculates the factorial. |
| Parameters | (int type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | fac |
| Declaration | varint fac( varint arg ) |
| Description | Calculates the factorial. |
| Parameters | (varint type) arg : The value to be calculated. |
| Return | (varint type) The calculated value. |
| Name | fac |
| Declaration | varfloat fac( varfloat arg ) |
| Description | Calculates the factorial. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | sin |
| Declaration | macro sin( float arg ) |
| Description | Calculates the sine function. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
float f = sin(1.0); print(f); // 0.84147... |
| Name | sin |
| Declaration | varfloat sin( varfloat arg ) |
| Description |
Calculates the sine function. Internally, it is calculated by Maclaurin expansion using "1.34 times the original number of digits plus 10 times the order of the argument" digits.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4, plus 10 times the order of the argument" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. For arguments outside the range from 0 to pi/2, the symmetry and periodicity of trigonometric functions are used, and internally the calculation is performed using values in the range from 0 to pi. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat v = sin(1.0vf); print(v); // 0.84147... |
| Name | cos |
| Declaration | macro cos( float arg ) |
| Description | Calculates the cosine function. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
float f = cos(1.0); print(f); // 0.5403... |
| Name | cos |
| Declaration | varfloat cos( varfloat arg ) |
| Description |
Calculates the cosine function. Internally, it is calculated by Maclaurin expansion using "1.34 times the original number of digits plus 10 times the order of the argument" digits.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4, plus 10 times the order of the argument" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. For arguments outside the range from 0 to pi/2, the symmetry and periodicity of trigonometric functions are used, and internally the calculation is performed using values in the range from 0 to pi. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat v = cos(1.0vf); print(v); // 0.5403... |
| Name | tan |
| Declaration | macro tan( float arg ) |
| Description | Calculates the tangent function. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Example |
float f = tan(1.0); print(f); // 1.5574... |
| Name | tan |
| Declaration | varfloat tan( varfloat arg ) |
| Description |
Calculates the tangent function. Internally, it is calculated by "tan(x) = sin(x) / cos(x)" using 2.1 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Example |
digit(50); varfloat v = tan(1.0vf); print(v); // 1.5574... |
| Name | asin |
| Declaration | macro asin( float arg ) |
| Description | Calculates the arcsine function, which is the inverse function of sine. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | asin |
| Declaration | varfloat asin( varfloat arg ) |
| Description |
Calculates the arcsine function, which is the inverse function of sine. Internally, it is calculated using 1.34 times the original number of digits, by Maclaurin expansion for arguments whose absolute value is 0.7 or less, and by Newton's method outside that range.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | acos |
| Declaration | macro acos( float arg ) |
| Description | Calculates the arccosine function, which is the inverse function of cosine. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | acos |
| Declaration | varfloat acos( varfloat arg ) |
| Description |
Calculates the arccosine function, which is the inverse function of cosine. Internally, it is calculated by "acos(x) = pi/2 - asin(x)" using 1.34 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | atan |
| Declaration | macro atan( float arg ) |
| Description | Calculates the arctangent function, which is the inverse function of tangent. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | atan |
| Declaration | varfloat atan( varfloat arg ) |
| Description |
Calculates the arctangent function, which is the inverse function of tangent. Internally, it is calculated using 1.34 times the original number of digits, by Maclaurin expansion for arguments whose absolute value is 0.7 or less, and by Newton's method outside that range.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | sinh |
| Declaration | macro sinh( float arg ) |
| Description | Calculates the hyperbolic sine function. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | sinh |
| Declaration | varfloat sinh( varfloat arg ) |
| Description |
Calculates the hyperbolic sine function. Internally, it is calculated by "sinh(x) = ( exp(x) - exp(-x) ) / 2" using 2.1 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | cosh |
| Declaration | macro cosh( float arg ) |
| Description | Calculates the hyperbolic cosine function. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | cosh |
| Declaration | varfloat cosh( varfloat arg ) |
| Description |
Calculates the hyperbolic cosine function. Internally, it is calculated by "cosh(x) = ( exp(x) + exp(-x) ) / 2" using 2.1 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | tanh |
| Declaration | macro tanh( float arg ) |
| Description | Calculates the hyperbolic tangent function. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | tanh |
| Declaration | varfloat tanh( varfloat arg ) |
| Description |
Calculates the hyperbolic tangent function. Internally, it is calculated by "tanh(x) = ( exp(x) - exp(-x) ) / ( exp(x) + exp(-x) )" using 2.8 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | asinh |
| Declaration | macro asinh( float arg ) |
| Description | Calculates the inverse hyperbolic sine function. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | asinh |
| Declaration | varfloat asinh( varfloat arg ) |
| Description |
Calculates the inverse hyperbolic sine function. Internally, it is calculated by "asinh(x) = ln( x + sqrt( x*x + 1 ) )" using 2.1 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | acosh |
| Declaration | macro acosh( float arg ) |
| Description | Calculates the inverse hyperbolic cosine function. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | acosh |
| Declaration | varfloat acosh( varfloat arg ) |
| Description |
Calculates the inverse hyperbolic cosine function. Internally, it is calculated by "acosh(x) = ln( x + sqrt( x*x - 1 ) )" using 2.1 times the original number of digits.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | atanh |
| Declaration | macro atanh( float arg ) |
| Description | Calculates the inverse hyperbolic tangent function. |
| Parameters | (float type) arg : The value to be calculated. |
| Return | The calculated value. |
| Name | atanh |
| Declaration | varfloat atanh( varfloat arg ) |
| Description |
Calculates the inverse hyperbolic tangent function. Internally, it is calculated using 2.1 times the original number of digits. For arguments whose absolute value is 0.9 or less, "atanh(x) = 1/2 * log(1+x)/log(1-x)" is used, and outside that range it is calculated by Newton's method.However, when the number of digits is 10 or less, it is calculated using "the original number of digits plus 4" digits. This extra number of digits may be changed in the future, probably in the direction of higher precision.By using the symmetry of the function, negative arguments are calculated using the value for the corresponding positive argument. In older versions, values could not be obtained for arguments less than or equal to -0.7, on the negative-infinity side. The calculation would not finish, or 0 would be returned. This problem was fixed in VCSSL 3.3.2. |
| Parameters | (varfloat type) arg : The value to be calculated. |
| Return | (varfloat type) The calculated value. |
| Name | deg |
| Declaration | macro deg( float rad ) |
| Description | Converts an angle from radians to degrees. |
| Parameters | (float type) rad : The angle in radians. |
| Return | The angle in degrees. |
| Example |
float f = deg(PI); print(f); // 180.0 |
| Name | deg |
| Declaration | varfloat deg(varfloat rad) |
| Description |
Converts an angle from radians to degrees. Internally, it is calculated using 1.34 times the original number of digits, by "radians = degrees * pi / 180". |
| Parameters | (varfloat type) rad : The angle in radians. |
| Return | (varfloat type) The angle in degrees. |
| Example |
digit(50); varfloat v = deg(pi()); print(v); // 179.999...9; print( round(v, 40v, HALF_UP) ); // 180.0 |
| Name | rad |
| Declaration | macro rad( float deg ) |
| Description | Converts an angle from degrees to radians. |
| Parameters | (float type) deg : The angle in degrees. |
| Return | The angle in radians. |
| Example |
float f = rad(180.0); print(f); // 3.14... |
| Name | rad |
| Declaration | varfloat rad(varfloat deg) |
| Description |
Converts an angle from degrees to radians. Internally, it is calculated using 1.34 times the original number of digits, by "degrees = radians * 180 / pi". |
| Parameters | (varfloat type) deg : The angle in degrees. |
| Return | (varfloat type) The angle in radians. |
| Example |
digit(50); varfloat v = rad(180.0vf); print(v); // 3.14... |