-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
executable file
·94 lines (63 loc) · 2.64 KB
/
README.txt
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
39
40
41
42
43
44
45
46
47
48
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
calc is a very simple calculator that is somewhat similar with the famous program expr.
[SYNOPSIS]
calc [options] OPu operand1
calc [options] operand1 OPb operand2
[DESCRIPTION]
calc is a very simple calculator, it calculates the
result of expressions and output the result to the standard output.
In the above synopsis:
OPu indicates an unary operator that only needs one operand.
e.g. ++, --, ~, !
OPb indicates an binary operator that needs two operands
e.g. +, -, *, /, %
calc supports only the simplest expressions.
Expressions passed to calc must meets the following restrictions:
* has only one operator
* has only one operand when the operator is an unary operator(OPu)
* has only two operands when the operator is an binary operator(OPb)
* with no brackets
[EXAMPLES]
The following are examples of valid usage.
To avoid expanding mechanism from shell, some operators are surrounded with " or '.
calc 1 + 2
calc 1 - 3
calc -3 "*" 8
calc 0x1234 "*" 0X5678
calc 0123 - 8
calc 0B10100101 "%" 0b1100
calc 1 "<<" 10
calc "++" 1023
calc "~" 0xF
calc '!' 0xF
calc 5 ">" 6
[OPERAND]
PREFIX BASE
0b/0B 2 (bin)
0 8 (octal)
0x/0X 16 (hex)
[+ or -]<1~9 > 10 (decimal)
[OPERATORS]
SYNTAX TYPE DESCRIPTION
+ - * / % ** unary normal arithmetical operators
++ -- ~ ! !! unary normal unary operators
& | ^ binary normal bitwise operators
<< >> binary normal shift operators
> >= < <= != binary normal relationship operators
[OPTIONS]
The default output format is signed decimal. However, following options can be
used to customize the output.
--output-base-2
--output-bin
output result in binary format.
--output-base-8
--output-oct
output result in octal format.
--output-base-16
--output-hex
output result in hex format.
--output-unsigned-decimal
output result in unsigned decimal format.
--output-no-prefix
output result without prefix such as 0/0x/0X/0b/0B.
[AUTHOR]
SUN Mingbao <[email protected]>