diff --git a/src/rpn-algebra.h b/src/rpn-algebra.h index e8cf08e..cc8f126 100644 --- a/src/rpn-algebra.h +++ b/src/rpn-algebra.h @@ -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)); +} diff --git a/src/rpn-cmd.h b/src/rpn-cmd.h index 259ce23..6c7c0b3 100644 --- a/src/rpn-cmd.h +++ b/src/rpn-cmd.h @@ -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"}, diff --git a/src/version.h b/src/version.h index 0aaf505..76f8d19 100644 --- a/src/version.h +++ b/src/version.h @@ -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 "; +static const char version[] = "1.3.3"; +static const char uname[] = "rpn v1.3.3, (c) 2015 "; 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