Added modulo fn

This commit is contained in:
Louis 2015-07-23 12:00:54 +02:00
parent b86ca1ffb1
commit c8faca978b
3 changed files with 18 additions and 3 deletions

View file

@ -179,3 +179,14 @@ void square()
floating_t first = getf();
putf(first * first);
}
void modulo()
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
// arithmetic faults are managed by c++
floating_t first = getf();
putf(fmodl(getf(), first));
}

View file

@ -30,6 +30,7 @@ program::keyword_t program::_keywords[] =
{ cmd_keyword, "^", &program::power, "binary operator power" },
{ cmd_keyword, "sqrt", &program::squareroot, "unarity operator square root" },
{ cmd_keyword, "sq", &program::square, "unarity operator square" },
{ cmd_keyword, "mod", &program::modulo, "binary operator modulo" },
//BINARY
{ cmd_undef, "", NULL, "\nBINARY"},

View file

@ -1,13 +1,16 @@
// version and soft name
static const char version[] = "1.3.2";
static const char uname[] = "rpn v1.3.2, (c) 2015 <louis@rubet.fr>";
static const char version[] = "1.3.3";
static const char uname[] = "rpn v1.3.3, (c) 2015 <louis@rubet.fr>";
static const char g_cursor[] = "> ";
static const string g_show_stack_separator = "> ";
// syntax
static const char* syntax[] = {
"Reverse Polish Notation language, based on hewlett-Packard RPL",
ATTR_BOLD "R" ATTR_OFF "everse "
ATTR_BOLD "P" ATTR_OFF "olish "
ATTR_BOLD "N" ATTR_OFF "otation language, based on hewlett-Packard RPL",
"",
"Syntax: rpn [command]",
"with optional command = list of commands",
NULL