calc(1)
| CALC(1) | Schily´s USER COMMANDS | CALC(1) |
NAME
calc - simple integer calculator that accepts decimal/hex/octal and outputs decimal/hex/octal/binary
SYNOPSIS
calc [ options ]
DESCRIPTION
The calc command may be used to do simple integer calculations or to convert numbers from one radix to another.
Calc reads commands from stdin and prints the result to stdout. The input radix for numbers may be decimal (default), octal (if starting with a '0') or hexadecimal (if starting with "0x"). The output is always printed in four radixes: decimal, octal, hexadecimal and binary. The decimal variant is printed as signed and as unsigned representation.
The result is printed in two variants using 32 bit and 64 bit representations for the numbers.
INPUT FORMAT
Calc accepts three types of input lines:
- one number
- The input line is one number only.
In this case the number is converted only to the different output formats.
- unary operator
- The input line is a unary operator followed by a number
In this case the unary operator is applied to the number and the result is printed in all output formats.
- binary operator
- The input line is a number followed by a binary operator followed by a
second number.
In this case the binary operator is applied to the numbers and the result is printed in all output formats.
OPERATORS
- +
- Binary arithmetic addition.
- -
- Binary arithmetic subtraction.
- *
- Binary arithmetic multiplication.
- <<
- Binary logical left shift.
- >>
- Binary logical right shift.
- ^
- Binary logical exclusive or as in C language.
- &
- Binary logical and masking as in C language.
- |
- Binary logical or as in C language.
- !
- Unary logical not as in C language.
- ~
- Unary logical one's complement as in C language.
- %
- Binary arithmetic remainder from division.
- /
- Binary arithmetic division.
OPTIONS
- -help
- Prints a short summary of the calc options and exists.
- -version
- Prints the calc version number string and exists.
SEE ALSO
BUGS
None currently known.
Mail bugs and suggestions to schilytools@mlists.in-berlin.de or open a ticket at https://codeberg.org/schilytools/schilytools/issues
The mailing list archive may be found at:
https://mlists.in-berlin.de/mailman/listinfo/schilytools-mlists.in-berlin.de
AUTHORS
Joerg Schilling and the schilytools project authors.
SOURCE DOWNLOAD
The source code for calc is included in the schilytools project and may be retrieved from the schilytools project at Codeberg at:
https://codeberg.org/schilytools/schilytools/
The download directory is:
https://codeberg.org/schilytools/schilytools/releases
| 2022/09/08 | Joerg Schilling |
