annotate src/float.c @ 24780:7bc92a651472 v8.2.2928

patch 8.2.2928: the evalfunc.c file is too big Commit: https://github.com/vim/vim/commit/01c798c31a94a50ad0c4a022fc21c1a31553be21 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Jun 2 17:07:18 2021 +0200 patch 8.2.2928: the evalfunc.c file is too big Problem: The evalfunc.c file is too big. Solution: Move float related functionality to a separate file. (Yegappan Lakshmanan, closes #8287)
author Bram Moolenaar <Bram@vim.org>
date Wed, 02 Jun 2021 17:15:03 +0200
parents
children 5f8dd7b3ae41
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24780
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * float.c: Floating point functions
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 #define USING_FLOAT_STUFF
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 #include "vim.h"
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 #if (defined(FEAT_EVAL) && defined(FEAT_FLOAT)) || defined(PROTO)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 #ifdef VMS
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 # include <float.h>
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 #endif
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 * Convert the string "text" to a floating point number.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 * This uses strtod(). setlocale(LC_NUMERIC, "C") has been used to make sure
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 * this always uses a decimal point.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 * Returns the length of the text that was consumed.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 int
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 string2float(
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 char_u *text,
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 float_T *value) // result stored here
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 char *s = (char *)text;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 float_T f;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 // MS-Windows does not deal with "inf" and "nan" properly.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 if (STRNICMP(text, "inf", 3) == 0)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 *value = INFINITY;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 return 3;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 if (STRNICMP(text, "-inf", 3) == 0)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 *value = -INFINITY;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 return 4;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 if (STRNICMP(text, "nan", 3) == 0)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 *value = NAN;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 return 3;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 f = strtod(s, &s);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 *value = f;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 return (int)((char_u *)s - text);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 * Get the float value of "argvars[0]" into "f".
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 * Returns FAIL when the argument is not a Number or Float.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 static int
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 get_float_arg(typval_T *argvars, float_T *f)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 if (argvars[0].v_type == VAR_FLOAT)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 *f = argvars[0].vval.v_float;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 return OK;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 if (argvars[0].v_type == VAR_NUMBER)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 *f = (float_T)argvars[0].vval.v_number;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 return OK;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 emsg(_("E808: Number or Float required"));
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 return FAIL;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 * "abs(expr)" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 f_abs(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 if (argvars[0].v_type == VAR_FLOAT)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 rettv->vval.v_float = fabs(argvars[0].vval.v_float);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 varnumber_T n;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 int error = FALSE;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 n = tv_get_number_chk(&argvars[0], &error);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 if (error)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 rettv->vval.v_number = -1;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 else if (n > 0)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 rettv->vval.v_number = n;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 rettv->vval.v_number = -n;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 * "acos()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 f_acos(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 rettv->vval.v_float = acos(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 * "asin()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 f_asin(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 rettv->vval.v_float = asin(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 * "atan()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 f_atan(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 rettv->vval.v_float = atan(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 * "atan2()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 f_atan2(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 float_T fx = 0.0, fy = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 if (get_float_arg(argvars, &fx) == OK
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 && get_float_arg(&argvars[1], &fy) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 rettv->vval.v_float = atan2(fx, fy);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 * "ceil({float})" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 f_ceil(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 rettv->vval.v_float = ceil(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 * "cos()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 f_cos(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 rettv->vval.v_float = cos(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 * "cosh()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 f_cosh(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 rettv->vval.v_float = cosh(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 * "exp()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 f_exp(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 rettv->vval.v_float = exp(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 * "float2nr({float})" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 f_float2nr(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 if (f <= (float_T)-VARNUM_MAX + DBL_EPSILON)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 rettv->vval.v_number = -VARNUM_MAX;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 else if (f >= (float_T)VARNUM_MAX - DBL_EPSILON)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 rettv->vval.v_number = VARNUM_MAX;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 rettv->vval.v_number = (varnumber_T)f;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 * "floor({float})" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 f_floor(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 rettv->vval.v_float = floor(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 * "fmod()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 f_fmod(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 float_T fx = 0.0, fy = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 if (get_float_arg(argvars, &fx) == OK
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 && get_float_arg(&argvars[1], &fy) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 rettv->vval.v_float = fmod(fx, fy);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 # if defined(HAVE_MATH_H) || defined(PROTO)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 * "isinf()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 f_isinf(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 if (argvars[0].v_type == VAR_FLOAT && isinf(argvars[0].vval.v_float))
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 rettv->vval.v_number = argvars[0].vval.v_float > 0.0 ? 1 : -1;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 * "isnan()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 f_isnan(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 rettv->vval.v_number = argvars[0].v_type == VAR_FLOAT
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 && isnan(argvars[0].vval.v_float);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 # endif
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 * "log()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 f_log(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 rettv->vval.v_float = log(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 * "log10()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 f_log10(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 rettv->vval.v_float = log10(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 * "pow()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 f_pow(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 float_T fx = 0.0, fy = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 if (get_float_arg(argvars, &fx) == OK
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 && get_float_arg(&argvars[1], &fy) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 rettv->vval.v_float = pow(fx, fy);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 * round() is not in C90, use ceil() or floor() instead.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 float_T
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 vim_round(float_T f)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 return f > 0 ? floor(f + 0.5) : ceil(f - 0.5);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 * "round({float})" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 f_round(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 rettv->vval.v_float = vim_round(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 * "sin()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 f_sin(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 rettv->vval.v_float = sin(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 * "sinh()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 f_sinh(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 rettv->vval.v_float = sinh(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 * "sqrt()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 f_sqrt(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 rettv->vval.v_float = sqrt(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 * "str2float()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 f_str2float(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 char_u *p = skipwhite(tv_get_string(&argvars[0]));
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 int isneg = (*p == '-');
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 if (*p == '+' || *p == '-')
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 p = skipwhite(p + 1);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 (void)string2float(p, &rettv->vval.v_float);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 if (isneg)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 rettv->vval.v_float *= -1;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 * "tan()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 f_tan(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 rettv->vval.v_float = tan(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 * "tanh()" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 f_tanh(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 rettv->vval.v_float = tanh(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 /*
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 * "trunc({float})" function
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 */
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 void
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 f_trunc(typval_T *argvars, typval_T *rettv)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 {
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 float_T f = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 rettv->v_type = VAR_FLOAT;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 if (get_float_arg(argvars, &f) == OK)
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 // trunc() is not in C90, use floor() or ceil() instead.
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 rettv->vval.v_float = f > 0 ? floor(f) : ceil(f);
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 else
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 rettv->vval.v_float = 0.0;
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 }
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476
7bc92a651472 patch 8.2.2928: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 #endif