fn-eng.c 17.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/*
 * fn-eng.c:  Built in engineering functions and functions registration
 *
 * Author:
 *  Michael Meeks <michael@imaginator.com>
 */
#include <config.h>
#include <gnome.h>
#include "math.h"
#include "numbers.h"
#include "gnumeric.h"
#include "gnumeric-sheet.h"
#include "utils.h"
#include "func.h"

#if 0
/* help template */
static char *help_ = {
	N_("@FUNCTION=NAME\n"
	   "@SYNTAX=(b1, b2, ...)\n"

	   "@DESCRIPTION"
	   ""
	   "\n"

	   ""
	   ""
	   "\n"
	   
	   ""
	   ""
	   ""
	   ""
	   "@SEEALSO=")
};

#endif

39 40 41 42 43 44 45 46 47
/**
 * FIXME: In the long term this needs optimising.
 **/
static Value *
val_to_base (Value *value, int src_base, int dest_base, int places ,char **error_string)
{
	int lp, max, bit, neg ;
	char *p, *ans ;
	char *err="\0", buffer[40], *str ;
Michael Meeks's avatar
Michael Meeks committed
48
	double v ;
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

	if (src_base<=1 || dest_base<=1) {
		*error_string = _("Base error") ;
		return NULL ;
	}

/*	printf ("Type: %d\n", value->type) ; */
	switch (value->type){
	case VALUE_STRING:
		str = value->v.str->str ;
		break ;
	case VALUE_INTEGER:
		snprintf (buffer, sizeof (buffer)-1, "%d", value->v.v_int);
		str = buffer ;
		break;
	case VALUE_FLOAT:
		snprintf (buffer, sizeof (buffer)-1, "%8.0f", value->v.v_float);
		str = buffer ;
		break;
	default:
		*error_string = _("#NUM!") ;
		return NULL ;
	}

	v = strtol (str, &err, src_base) ;
	if (*err) {
		*error_string = _("#NUM!") ;
		return NULL ;
	}

Michael Meeks's avatar
Michael Meeks committed
79
	if (v >= (pow (src_base, 10)/2.0)) /* N's complement */
80 81 82 83 84 85 86
		v = -v ;

	if (dest_base == 10)
		return (value_int(v)) ;

	if (v<0) {
		neg = 1 ;
Michael Meeks's avatar
Michael Meeks committed
87
		v = -v ;
88 89 90
	}
	else
		neg = 0 ;
Michael Meeks's avatar
Michael Meeks committed
91 92 93 94 95 96 97 98 99
	
	if (neg) /* Pad the number */
		max = 10 ;
	else {
		if (v==0)
			max = 1 ;
		else
			max = (int)(log(v)/log(dest_base)) + 1 ;
	}
100 101 102

	if (places>max)
		max = places ;
Michael Meeks's avatar
Michael Meeks committed
103
	if (max > 15) {
104 105 106 107 108 109 110
		*error_string = _("Unimplemented") ;
		return NULL ;
	}

	ans = buffer ;
	p = &ans[max-1] ;
	for (lp = 0; lp < max; lp++) {
Michael Meeks's avatar
Michael Meeks committed
111 112
		bit = ((int)v) % dest_base ;
		v   = fabs (v / (double)dest_base) ;
113
		if (neg)
Michael Meeks's avatar
Michael Meeks committed
114
			bit = dest_base-bit-1 ;
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
		if (bit>=0 && bit <= 9)
			*p-- = '0'+bit ;
		else
			*p-- = 'A'+bit-10 ;

		if (places>0 && lp>=places) {
			if (v == 0)
				break ;
			else {
				*error_string = _("#NUM!") ;
				return NULL ;
			}
		}
	}
	ans[max] = '\0' ;
	return value_str(ans) ;
}

static Value *
val_to_base_place (void *sheet, GList *l, int eval_col, int eval_row, char **error_string,
		   int src_base, int dest_base)
{
	int argc = g_list_length (l) ;
	Value *ans, *num, *val_places=0 ;
	int places = -1 ;

	if (argc < 1 || argc > 2 || !l->data) {
		*error_string = _("Invalid number of arguments") ;
		return NULL ;
	}

	if (!(num = eval_expr (sheet, l->data, eval_col, eval_row, error_string)))
		return NULL ;

	l = g_list_next(l) ;
	if (l && l->data) {
		val_places = eval_expr (sheet, l->data, eval_col, eval_row, error_string) ;
		if (!val_places)
			return NULL ;
		else if (val_places->type != VALUE_INTEGER &&
		    val_places->type != VALUE_FLOAT) {
			*error_string = _("#VALUE!") ;
			return NULL ;
		}
		places = value_get_as_int (val_places) ;
		value_release (val_places) ;
	}
	
	ans = val_to_base (num, src_base, dest_base, places, error_string) ;
	value_release (num) ;
	return ans ;
}

168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
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"
	   "\n"
	   "@SEEALSO=DEC2BIN")
};

static Value *
gnumeric_bin2dec (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
183 184
	return val_to_base (argv[0], 2, 10, -1, error_string) ;
}
185

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
static char *help_bin2oct = {
	N_("@FUNCTION=BIN2OCT\n"
	   "@SYNTAX=BIN2OCT(number,places)\n"

	   "@DESCRIPTION="
	   "The BIN2OCT function converts a binary number to an octal number."
	   "places is an optional field, specifying to zero pad to that number of spaces."
	   "\n"
	   "if places is too small or negative #NUM! error is returned."
	   "\n"
	   "@SEEALSO=OCT2BIN")
};

static Value *
gnumeric_bin2oct (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	return val_to_base_place (sheet, l, eval_col, eval_row, error_string,
				  2, 8) ;
}

static char *help_bin2hex = {
	N_("@FUNCTION=BIN2HEX\n"
	   "@SYNTAX=BIN2HEX(number,places)\n"

	   "@DESCRIPTION="
	   "The BIN2HEX function converts a binary number to a hexadecimal number."
	   "places is an optional field, specifying to zero pad to that number of spaces."
	   "\n"
	   "if places is too small or negative #NUM! error is returned."
	   "\n"
	   "@SEEALSO=HEX2BIN")
};

static Value *
gnumeric_bin2hex (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	return val_to_base_place (sheet, l, eval_col, eval_row, error_string,
				  2, 16) ;
}

static char *help_dec2bin = {
	N_("@FUNCTION=DEC2BIN\n"
	   "@SYNTAX=DEC2BIN(number,places)\n"

	   "@DESCRIPTION="
	   "The DEC2BIN function converts a binary number to an octal number."
	   "places is an optional field, specifying to zero pad to that number of spaces."
	   "\n"
	   "if places is too small or negative #NUM! error is returned."
	   "\n"
	   "@SEEALSO=BIN2DEC")
};

static Value *
gnumeric_dec2bin (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	return val_to_base_place (sheet, l, eval_col, eval_row, error_string,
				  10, 2) ;
}

static char *help_dec2oct = {
	N_("@FUNCTION=DEC2OCT\n"
	   "@SYNTAX=DEC2OCT(number,places)\n"

	   "@DESCRIPTION="
	   "The DEC2OCT function converts a binary number to an octal number."
	   "places is an optional field, specifying to zero pad to that number of spaces."
	   "\n"
	   "if places is too small or negative #NUM! error is returned."
	   "\n"
	   "@SEEALSO=OCT2DEC")
};

static Value *
gnumeric_dec2oct (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	return val_to_base_place (sheet, l, eval_col, eval_row, error_string,
				  10, 8) ;
}

static char *help_dec2hex = {
	N_("@FUNCTION=DEC2HEX\n"
	   "@SYNTAX=DEC2HEX(number,places)\n"

	   "@DESCRIPTION="
	   "The DEC2HEX function converts a binary number to an octal number."
	   "places is an optional field, specifying to zero pad to that number of spaces."
	   "\n"
	   "if places is too small or negative #NUM! error is returned."
	   "\n"
	   "@SEEALSO=HEX2DEC")
};

static Value *
gnumeric_dec2hex (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	return val_to_base_place (sheet, l, eval_col, eval_row, error_string,
				  10, 16) ;
}

static char *help_oct2dec = {
	N_("@FUNCTION=OCT2DEC\n"
	   "@SYNTAX=OCT2DEC(x)\n"

	   "@DESCRIPTION="
	   "The OCT2DEC function converts an octal number "
	   "in a string or number to its decimal equivalent."
	   "\n"
	   "\n"
	   "@SEEALSO=DEC2OCT")
};

static Value *
gnumeric_oct2dec (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
	return val_to_base (argv[0], 8, 10, -1, error_string) ;
}

static char *help_oct2bin = {
	N_("@FUNCTION=OCT2BIN\n"
	   "@SYNTAX=OCT2BIN(number,places)\n"

	   "@DESCRIPTION="
	   "The OCT2BIN function converts a binary number to a hexadecimal number."
	   "places is an optional field, specifying to zero pad to that number of spaces."
	   "\n"
	   "if places is too small or negative #NUM! error is returned."
	   "\n"
	   "@SEEALSO=BIN2OCT")
};

static Value *
gnumeric_oct2bin (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	return val_to_base_place (sheet, l, eval_col, eval_row, error_string,
				  8, 2) ;
}

static char *help_oct2hex = {
	N_("@FUNCTION=OCT2HEX\n"
	   "@SYNTAX=OCT2HEX(number,places)\n"

	   "@DESCRIPTION="
	   "The OCT2HEX function converts a binary number to a hexadecimal number."
	   "places is an optional field, specifying to zero pad to that number of spaces."
	   "\n"
	   "if places is too small or negative #NUM! error is returned."
	   "\n"
	   "@SEEALSO=OCT2HEX")
};

static Value *
gnumeric_oct2hex (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	return val_to_base_place (sheet, l, eval_col, eval_row, error_string,
				  8, 16) ;
}

static char *help_hex2bin = {
	N_("@FUNCTION=HEX2BIN\n"
	   "@SYNTAX=HEX2BIN(number,places)\n"

	   "@DESCRIPTION="
	   "The HEX2BIN function converts a binary number to a hexadecimal number."
	   "places is an optional field, specifying to zero pad to that number of spaces."
	   "\n"
	   "if places is too small or negative #NUM! error is returned."
	   "\n"
	   "@SEEALSO=BIN2HEX")
};

static Value *
gnumeric_hex2bin (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	return val_to_base_place (sheet, l, eval_col, eval_row, error_string,
				  16, 2) ;
}

static char *help_hex2oct = {
	N_("@FUNCTION=HEX2OCT\n"
	   "@SYNTAX=HEX2OCT(number,places)\n"

	   "@DESCRIPTION="
	   "The HEX2OCT function converts a binary number to a hexadecimal number."
	   "places is an optional field, specifying to zero pad to that number of spaces."
	   "\n"
	   "if places is too small or negative #NUM! error is returned."
	   "\n"
	   "@SEEALSO=BIN2HEX")
};

static Value *
gnumeric_hex2oct (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	return val_to_base_place (sheet, l, eval_col, eval_row, error_string,
				  16, 8) ;
}

static char *help_hex2dec = {
	N_("@FUNCTION=HEX2DEC\n"
	   "@SYNTAX=HEX2DEC(x)\n"

	   "@DESCRIPTION="
	   "The HEX2DEC function converts a binary number "
	   "in string or number to its decimal equivalent."
	   "\n"
	   "\n"
	   "@SEEALSO=DEC2HEX")
};

static Value *
gnumeric_hex2dec (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
	return val_to_base (argv[0], 16, 10, -1, error_string) ;
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
}

static char *help_besselj = {
	N_("@FUNCTION=BESSELJ\n"
	   "@SYNTAX=BESSELJ(x,y)\n"

	   "@DESCRIPTION="
	   "The BESSELJ function returns the bessel function with "
	   "x is where the function is evaluated. "
	   "y is the order of the bessel function, if non-integer it is truncated. "
	   "\n"

	   "if x or n are not numeric a #VALUE! error is returned."
	   "if n < 0 a #NUM! error is returned." 
	   "\n"
	   "@SEEALSO=BESSELJ,BESSELK,BESSELY")
};

static Value *
gnumeric_besselj (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
	int y ;
	if (argv[0]->type != VALUE_INTEGER &&
	    argv[1]->type != VALUE_INTEGER &&
	    argv[0]->type != VALUE_FLOAT &&
	    argv[1]->type != VALUE_FLOAT) {
		*error_string = _("#VALUE!") ;
		return NULL ;
	}
	if ((y=value_get_as_int(argv[1]))<0) {
		*error_string = _("#NUM!") ;
		return NULL ;
	}
	return value_float (jn (y, value_get_as_double (argv [0])));
}

static char *help_bessely = {
	N_("@FUNCTION=BESSELY\n"
	   "@SYNTAX=BESSELY(x,y)\n"

	   "@DESCRIPTION="
	   "The BESSELY function returns the Neumann, Weber or Bessel function. "
	   "x is where the function is evaluated. "
	   "y is the order of the bessel function, if non-integer it is truncated. "
	   "\n"

	   "if x or n are not numeric a #VALUE! error is returned."
	   "if n < 0 a #NUM! error is returned." 
	   "\n"
	   "@SEEALSO=BESSELJ,BESSELK,BESSELY")
};

static Value *
gnumeric_bessely (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
	int y ;
	if (argv[0]->type != VALUE_INTEGER &&
	    argv[1]->type != VALUE_INTEGER &&
	    argv[0]->type != VALUE_FLOAT &&
	    argv[1]->type != VALUE_FLOAT) {
		*error_string = _("#VALUE!") ;
		return NULL ;
	}
	if ((y=value_get_as_int(argv[1]))<0) {
		*error_string = _("#NUM!") ;
		return NULL ;
	}
	return value_float (yn (y, value_get_as_double (argv [0])));
}

static char *help_erf = {
	N_("@FUNCTION=ERF\n"
	   "@SYNTAX=ERF(lower limit, upper_limit)\n"

	   "@DESCRIPTION="
	   "The ERF function returns the integral of the error function between the limits. "
	   "If the upper limit ommitted ERF returns the integral between zero and the lower limit"
	   "\n"

	   "if either lower or upper are not numeric a #VALUE! error is returned."
	   "if either lower or upper are < 0 a #NUM! error is returned."
	   "\n"
	   "@SEEALSO=ERFC")
};


static Value *
487
gnumeric_erf (struct FunctionDefinition *i, Value *argv [], char **error_string)
488 489 490
{
	float_t ans, lower, upper=0.0 ;

491 492 493
	lower = value_get_as_double(argv[0]) ;
	if (argv[1])
		upper = value_get_as_double(argv[1]) ;
494 495 496 497 498 499 500
	
	if (lower < 0.0 || upper < 0.0) {
		*error_string = _("#NUM!") ;
		return NULL ;
	}
	       
	ans = erf(lower) ;
501
	if (argv[1])
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
		ans = erf(upper) - ans ;
	
	return value_float (ans) ;
}

static char *help_erfc = {
	N_("@FUNCTION=ERFC\n"
	   "@SYNTAX=ERFC(x)\n"

	   "@DESCRIPTION="
	   "The ERFC function returns the integral of the complimentary error function between the limits 0 and x. "
	   "\n"

	   "if x is not numeric a #VALUE! error is returned."
	   "if x < 0 a #NUM! error is returned."
	   "\n"
	   "@SEEALSO=ERF")
};

static Value *
gnumeric_erfc (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
	float_t x ;
	if ((x=value_get_as_double(argv[0]))<0) {
		*error_string = _("#NUM!") ;
		return NULL ;
	}
	return value_float (erfc (x)) ;
}

static char *help_delta = {
	N_("@FUNCTION=DELTA\n"
	   "@SYNTAX=DELTA(x,y)\n"

	   "@DESCRIPTION="
	   "The DELTA function test for numerical eqivilance of two arguments returning 1 in equality "
	   "y is optional, and defaults to 0"
	   "\n"

	   "if either argument is non-numeric returns a #VALUE! error"
	   "\n"
	   "@SEEALSO=EXACT,GESTEP")
};


static Value *
548
gnumeric_delta (struct FunctionDefinition *i, Value *argv [], char **error_string)
549 550 551 552
{
	int ans = 0 ;
	Value *vx, *vy ;

553 554 555
	vx = argv[0] ;
	if (argv[1])
		vy = argv[1] ;
556
	else
557 558
		vy = value_int(0) ;

559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
	switch (vx->type)
	{
	case VALUE_INTEGER:
		switch (vy->type)
		{
		case VALUE_INTEGER:
			if (vx->v.v_int == vy->v.v_int)
				ans = 1 ;
			break ;
		case VALUE_FLOAT:
			if (vy->v.v_float == (float_t)vx->v.v_int)
				ans = 1 ;
			break ;
		default:
			*error_string = _("Impossible") ;
			return NULL ;
		}
		break ;
	case VALUE_FLOAT:
		switch (vy->type)
		{
		case VALUE_INTEGER:
			if (vx->v.v_float == (float_t)vy->v.v_int)
				ans = 1 ;
			break ;
		case VALUE_FLOAT:
			if (vy->v.v_float == vx->v.v_float)
				ans = 1 ;
			break ;
		default:
			*error_string = _("Impossible") ;
			return NULL ;
		}
		break ;
	default:
		*error_string = _("Impossible") ;
		return NULL ;
	}
	       
	return value_int (ans) ;
}

601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713
static char *help_gestep = {
	N_("@FUNCTION=GESTEP\n"
	   "@SYNTAX=GESTEP(x,y)\n"

	   "@DESCRIPTION="
	   "The GESTEP function test for if x is >= y, returning 1 if it is so, and 0 otherwise "
	   "y is optional, and defaults to 0"
	   "\n"

	   "if either argument is non-numeric returns a #VALUE! error"
	   "\n"
	   "@SEEALSO=DELTA")
};


static Value *
gnumeric_gestep (void *sheet, GList *l, int eval_col, int eval_row, char **error_string)
{
	int ans = 0 ;
	int argc = g_list_length (l) ;
	Value *vx, *vy ;

	if (argc < 1 || argc > 2 || !l->data) {
		*error_string = _("Invalid number of arguments") ;
		return NULL ;
	}

	vx = eval_expr (sheet, l->data, eval_col, eval_row, error_string) ;
	if (vx->type != VALUE_INTEGER &&
	    vx->type != VALUE_FLOAT) {
		*error_string = _("#VALUE!") ;
		return NULL ;
	}
	
	l = g_list_next(l) ;
	if (l && l->data) {
		vy = eval_expr (sheet, l->data, eval_col, eval_row, error_string) ;
		if (vy->type != VALUE_INTEGER &&
		    vy->type != VALUE_FLOAT) {
			*error_string = _("#VALUE!") ;
			return NULL ;
		}
	}
	else
		vy = value_int (0) ;
	switch (vx->type)
	{
	case VALUE_INTEGER:
		switch (vy->type)
		{
		case VALUE_INTEGER:
			if (vx->v.v_int >= vy->v.v_int)
				ans = 1 ;
			break ;
		case VALUE_FLOAT:
			if (vy->v.v_float < (float_t)vx->v.v_int)
				ans = 1 ;
			break ;
		default:
			*error_string = _("Impossible") ;
			return NULL ;
		}
		break ;
	case VALUE_FLOAT:
		switch (vy->type)
		{
		case VALUE_INTEGER:
			if (vx->v.v_float >= (float_t)vy->v.v_int)
				ans = 1 ;
			break ;
		case VALUE_FLOAT:
			if (vy->v.v_float < vx->v.v_float)
				ans = 1 ;
			break ;
		default:
			*error_string = _("Impossible") ;
			return NULL ;
		}
		break ;
	default:
		*error_string = _("Impossible") ;
		return NULL ;
	}
	       
	value_release (vx) ;
	value_release (vy) ;
	return value_int (ans) ;
}

static char *help_sqrtpi = {
	N_("@FUNCTION=SQRTPI\n"
	   "@SYNTAX=SQRTPI(x)\n"

	   "@DESCRIPTION="
	   "The SQRTPI returns the square root of PI * x. "
	   "\n"

	   "if x < 0 a #NUM! error is returned."
	   "\n"
	   "@SEEALSO=ERF")
};

static Value *
gnumeric_sqrtpi (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
	float_t x ;
	if ((x=value_get_as_double(argv[0]))<0) {
		*error_string = _("#NUM!") ;
		return NULL ;
	}
	return value_float (sqrt (M_PI*x)) ;
}

714 715 716 717
FunctionDefinition eng_functions [] = {
	{ "bessely",   "ff",   "xnum,ynum",   &help_bessely, NULL, gnumeric_bessely },
	{ "besselj",   "ff",   "xnum,ynum",   &help_besselj, NULL, gnumeric_besselj },
	{ "bin2dec",   "?",    "number",      &help_bin2dec, NULL, gnumeric_bin2dec },
718 719 720 721 722
	{ "bin2hex",   0,      "xnum,ynum",   &help_bin2hex, gnumeric_bin2hex, NULL },
	{ "bin2oct",   0,      "xnum,ynum",   &help_bin2oct, gnumeric_bin2oct, NULL },
	{ "dec2bin",   0,      "xnum,ynum",   &help_dec2bin, gnumeric_dec2bin, NULL },
	{ "dec2oct",   0,      "xnum,ynum",   &help_dec2oct, gnumeric_dec2oct, NULL },
	{ "dec2hex",   0,      "xnum,ynum",   &help_dec2hex, gnumeric_dec2hex, NULL },
723 724
	{ "delta",     "f|f",  "xnum,ynum",   &help_delta,   NULL, gnumeric_delta },
	{ "erf",       "f|f",  "lower,upper", &help_erf,     NULL, gnumeric_erf  },
725
	{ "erfc",      "f",    "number",      &help_erfc,    NULL, gnumeric_erfc },
726 727 728 729 730 731 732 733
	{ "gestep",    0,      "xnum,ynum",   &help_gestep,  gnumeric_gestep, NULL },
	{ "hex2bin",   0,      "xnum,ynum",   &help_hex2bin, gnumeric_hex2bin, NULL },
	{ "hex2dec",   "?",    "number",      &help_hex2dec, NULL, gnumeric_hex2dec },
	{ "hex2oct",   0,      "xnum,ynum",   &help_hex2oct, gnumeric_hex2oct, NULL },
	{ "oct2bin",   0,      "xnum,ynum",   &help_oct2bin, gnumeric_oct2bin, NULL },
	{ "oct2dec",   "?",    "number",      &help_oct2dec, NULL, gnumeric_oct2dec },
	{ "oct2hex",   0,      "xnum,ynum",   &help_oct2hex, gnumeric_oct2hex, NULL },
	{ "sqrtpi",    "f",    "number",      &help_sqrtpi,  NULL, gnumeric_sqrtpi },
734 735 736 737 738 739 740 741 742 743 744
	/* besseli */
	/* besselk */
	{ NULL, NULL },
};


/*
 * Mode, Median: Use large hash table :-)
 *
 * Engineering: Bessel functions: use C fns: j0, y0 etc.
 */