mirror of
https://github.com/louisrubet/rpn
synced 2024-11-17 07:47:50 +01:00
Added modulo fn
This commit is contained in:
parent
b86ca1ffb1
commit
c8faca978b
3 changed files with 18 additions and 3 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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"},
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue