Commit 99a990bb authored by Michael Meeks's avatar Michael Meeks
Browse files

Implemented 4 new engineering functions.

parent 30ed3786
1999-03-13 Michael Meeks <michael@imaginator.com>
* src/fn-eng.c: Created
(gnumeric_erf, gnumeric_erfc, gnumeric_bessely)
(gnumeric_besselj): Implemented
(gnumeric_bin2dec): Moved from fn-math.c
* src/fn-math.c (gnumeric_bin2dec): Moved to fn-eng
* src/func.c (functions_init): Added eng_functions.
* src/fn-stat.c: Cleaned functions help.
* src/Makefile.am: Added fn-eng.c
1999-03-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/clipboard.c (sheet_paste_selection): New routine. Abstracts
......
1999-03-13 Michael Meeks <michael@imaginator.com>
* src/fn-eng.c: Created
(gnumeric_erf, gnumeric_erfc, gnumeric_bessely)
(gnumeric_besselj): Implemented
(gnumeric_bin2dec): Moved from fn-math.c
* src/fn-math.c (gnumeric_bin2dec): Moved to fn-eng
* src/func.c (functions_init): Added eng_functions.
* src/fn-stat.c: Cleaned functions help.
* src/Makefile.am: Added fn-eng.c
1999-03-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/clipboard.c (sheet_paste_selection): New routine. Abstracts
......
1999-03-13 Michael Meeks <michael@imaginator.com>
* src/fn-eng.c: Created
(gnumeric_erf, gnumeric_erfc, gnumeric_bessely)
(gnumeric_besselj): Implemented
(gnumeric_bin2dec): Moved from fn-math.c
* src/fn-math.c (gnumeric_bin2dec): Moved to fn-eng
* src/func.c (functions_init): Added eng_functions.
* src/fn-stat.c: Cleaned functions help.
* src/Makefile.am: Added fn-eng.c
1999-03-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/clipboard.c (sheet_paste_selection): New routine. Abstracts
......
1999-03-13 Michael Meeks <michael@imaginator.com>
* src/fn-eng.c: Created
(gnumeric_erf, gnumeric_erfc, gnumeric_bessely)
(gnumeric_besselj): Implemented
(gnumeric_bin2dec): Moved from fn-math.c
* src/fn-math.c (gnumeric_bin2dec): Moved to fn-eng
* src/func.c (functions_init): Added eng_functions.
* src/fn-stat.c: Cleaned functions help.
* src/Makefile.am: Added fn-eng.c
1999-03-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/clipboard.c (sheet_paste_selection): New routine. Abstracts
......
......@@ -382,56 +382,6 @@ gnumeric_ceil (struct FunctionDefinition *i, Value *argv [], char **error_string
return value_float (ceil (value_get_as_double (argv [0])));
}
static char *help_bin2dec = {
N_("@FUNCTION=BIN2DEC\n"
"@SYNTAX=BIN2DEC(x)\n"
"@DESCRIPTION="
"The BIN2DEC function converts a binary number "
"in string or number to its decimal equivalent."
"\n"
"Performing this function on a string or empty cell simply does nothing."
"\n"
"@SEEALSO=DEC2BIN")
};
static Value *
gnumeric_bin2dec (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
int result, v, n, bit;
char *p;
result = 0;
switch (argv [0]->type){
case VALUE_INTEGER:
v = argv [0]->v.v_int;
n = 0;
for (n = 0; v; n++){
bit = v % 10;
v = v / 10;
result |= bit << n;
}
break;
case VALUE_STRING:
p = argv [0]->v.str->str;
for (;*p; p++){
if (!(*p == '0' || *p == '1')){
*error_string = "#NUM!";
return NULL;
}
result = result << 1 | (*p - '0');
}
break;
default:
*error_string = "#NUM!";
return NULL;
}
return value_int (result);
}
static char *help_cos = {
N_("@FUNCTION=COS\n"
"@SYNTAX=COS(x)\n"
......@@ -1218,11 +1168,6 @@ FunctionDefinition math_functions [] = {
{ "atan2", "ff", "xnum,ynum", &help_atan2, NULL, gnumeric_atan2 },
/* avedev */
{ "average", 0, "", &help_average, gnumeric_average, NULL },
/* besseli */
/* besselj */
/* besselk */
/* bessely */
{ "bin2dec", "?", "number", &help_bin2dec, NULL, gnumeric_bin2dec },
{ "cos", "f", "number", &help_cos, NULL, gnumeric_cos },
{ "cosh", "f", "number", &help_cosh, NULL, gnumeric_cosh },
{ "count", 0, "", &help_count, gnumeric_count, NULL },
......
......@@ -256,8 +256,8 @@ static char *help_expondist = {
"The EXPONDIST function returns the exponential distribution "
"If the cumulative boolean is false it will return: "
"y * exp (-y*x), otherwise it will return 1 - exp (-y*x). "
"If x<0 or y<=0 this will return an error"
"\n"
"If x<0 or y<=0 this will return an error"
"Performing this function on a string or empty cell simply does nothing. "
"\n"
"@SEEALSO=POISSON")
......
......@@ -48,11 +48,12 @@ GNUMERIC_BASE_SOURCES = \
func.c \
func.h \
fn-date.c \
fn-eng.c \
fn-financial.c \
fn-math.c \
fn-stat.c \
fn-misc.c \
fn-sheet.c \
fn-stat.c \
fn-string.c \
format.c \
format.h \
......
......@@ -382,56 +382,6 @@ gnumeric_ceil (struct FunctionDefinition *i, Value *argv [], char **error_string
return value_float (ceil (value_get_as_double (argv [0])));
}
static char *help_bin2dec = {
N_("@FUNCTION=BIN2DEC\n"
"@SYNTAX=BIN2DEC(x)\n"
"@DESCRIPTION="
"The BIN2DEC function converts a binary number "
"in string or number to its decimal equivalent."
"\n"
"Performing this function on a string or empty cell simply does nothing."
"\n"
"@SEEALSO=DEC2BIN")
};
static Value *
gnumeric_bin2dec (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
int result, v, n, bit;
char *p;
result = 0;
switch (argv [0]->type){
case VALUE_INTEGER:
v = argv [0]->v.v_int;
n = 0;
for (n = 0; v; n++){
bit = v % 10;
v = v / 10;
result |= bit << n;
}
break;
case VALUE_STRING:
p = argv [0]->v.str->str;
for (;*p; p++){
if (!(*p == '0' || *p == '1')){
*error_string = "#NUM!";
return NULL;
}
result = result << 1 | (*p - '0');
}
break;
default:
*error_string = "#NUM!";
return NULL;
}
return value_int (result);
}
static char *help_cos = {
N_("@FUNCTION=COS\n"
"@SYNTAX=COS(x)\n"
......@@ -1218,11 +1168,6 @@ FunctionDefinition math_functions [] = {
{ "atan2", "ff", "xnum,ynum", &help_atan2, NULL, gnumeric_atan2 },
/* avedev */
{ "average", 0, "", &help_average, gnumeric_average, NULL },
/* besseli */
/* besselj */
/* besselk */
/* bessely */
{ "bin2dec", "?", "number", &help_bin2dec, NULL, gnumeric_bin2dec },
{ "cos", "f", "number", &help_cos, NULL, gnumeric_cos },
{ "cosh", "f", "number", &help_cosh, NULL, gnumeric_cosh },
{ "count", 0, "", &help_count, gnumeric_count, NULL },
......
......@@ -256,8 +256,8 @@ static char *help_expondist = {
"The EXPONDIST function returns the exponential distribution "
"If the cumulative boolean is false it will return: "
"y * exp (-y*x), otherwise it will return 1 - exp (-y*x). "
"If x<0 or y<=0 this will return an error"
"\n"
"If x<0 or y<=0 this will return an error"
"Performing this function on a string or empty cell simply does nothing. "
"\n"
"@SEEALSO=POISSON")
......
......@@ -160,6 +160,7 @@ functions_init (void)
install_symbols (string_functions);
install_symbols (stat_functions);
install_symbols (finance_functions);
install_symbols (eng_functions);
}
void
......
......@@ -8,6 +8,7 @@ extern FunctionDefinition date_functions [];
extern FunctionDefinition string_functions [];
extern FunctionDefinition stat_functions [];
extern FunctionDefinition finance_functions [];
extern FunctionDefinition eng_functions [];
typedef int (*FunctionIterateCallback)(Sheet *sheet, Value *value, char **error_string, void *);
......
......@@ -382,56 +382,6 @@ gnumeric_ceil (struct FunctionDefinition *i, Value *argv [], char **error_string
return value_float (ceil (value_get_as_double (argv [0])));
}
static char *help_bin2dec = {
N_("@FUNCTION=BIN2DEC\n"
"@SYNTAX=BIN2DEC(x)\n"
"@DESCRIPTION="
"The BIN2DEC function converts a binary number "
"in string or number to its decimal equivalent."
"\n"
"Performing this function on a string or empty cell simply does nothing."
"\n"
"@SEEALSO=DEC2BIN")
};
static Value *
gnumeric_bin2dec (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
int result, v, n, bit;
char *p;
result = 0;
switch (argv [0]->type){
case VALUE_INTEGER:
v = argv [0]->v.v_int;
n = 0;
for (n = 0; v; n++){
bit = v % 10;
v = v / 10;
result |= bit << n;
}
break;
case VALUE_STRING:
p = argv [0]->v.str->str;
for (;*p; p++){
if (!(*p == '0' || *p == '1')){
*error_string = "#NUM!";
return NULL;
}
result = result << 1 | (*p - '0');
}
break;
default:
*error_string = "#NUM!";
return NULL;
}
return value_int (result);
}
static char *help_cos = {
N_("@FUNCTION=COS\n"
"@SYNTAX=COS(x)\n"
......@@ -1218,11 +1168,6 @@ FunctionDefinition math_functions [] = {
{ "atan2", "ff", "xnum,ynum", &help_atan2, NULL, gnumeric_atan2 },
/* avedev */
{ "average", 0, "", &help_average, gnumeric_average, NULL },
/* besseli */
/* besselj */
/* besselk */
/* bessely */
{ "bin2dec", "?", "number", &help_bin2dec, NULL, gnumeric_bin2dec },
{ "cos", "f", "number", &help_cos, NULL, gnumeric_cos },
{ "cosh", "f", "number", &help_cosh, NULL, gnumeric_cosh },
{ "count", 0, "", &help_count, gnumeric_count, NULL },
......
......@@ -256,8 +256,8 @@ static char *help_expondist = {
"The EXPONDIST function returns the exponential distribution "
"If the cumulative boolean is false it will return: "
"y * exp (-y*x), otherwise it will return 1 - exp (-y*x). "
"If x<0 or y<=0 this will return an error"
"\n"
"If x<0 or y<=0 this will return an error"
"Performing this function on a string or empty cell simply does nothing. "
"\n"
"@SEEALSO=POISSON")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment