-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmul.cpp
More file actions
33 lines (28 loc) · 674 Bytes
/
mul.cpp
File metadata and controls
33 lines (28 loc) · 674 Bytes
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
#include <command>
/*
NAME
mul - multiply two integers and store the result
SYNOPSIS
mul <output> <a> <b>
DESCRIPTION
Expands variables in the numeric inputs, multiplies the two integer values,
and stores the result in <output>.
*/
REGISTER_COMMAND
{
auto vars = args;
DEREFERENCE(vars);
const auto& splitVars = utils::split(vars);
if (splitVars.size() != 3)
ERROR("requires 3 arguments <output> <a> <b>");
try
{
const int a = std::stoi(splitVars[1].c_str());
const int b = std::stoi(splitVars[2].c_str());
SET_VARIABLE(splitVars[0], std::to_string(a * b));
}
catch (std::exception& e)
{
ERROR("Input values must be integers");
}
};