# calc(3)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

calc - Integer calculator

## SYNOPSIS

n calc "string"

## DESCRIPTION

calc can perform simple integer based calculations given by "string", where the "string" takes the following form:-

    "[b]<s>"

Where 'b' is an optional letter setting the required output base which can be one of the following:

`b` - Binary
`o` - Octal
`d` - Decimal
`x` - Hexadecimal

Default when omitted is 'd' (decimal). "s" is the sum to be calculated, which should be bodmas in form. Following is a list of valid symbols.

`(..)` - Parentheses (contents calculated first)
`!` - Logical not
`&&` - Logical and
`||` - Logical or
`==` - Logical equals
`!=` - Logical not equals
`~` - Bitwise not
`&` - Bitwise and
`|` - Bitwise or
`^` - Bitwise xor
`/` - Divide
`*` - Multiply
`%` - Modulus
`+` - Addition
`-` - Subtraction
`0xNN` - Hexadecimal number
`0NN` - Octal number
`LR` - Last calculation recall

Any MicroEmacs variables can be used in the calculation. The result of the calculation is stored in .calc.result(5). The argument n is a bitwise flag where:

0x01

Print out the result on the message-line.

0x02

Use string comparisons for == and != comparisons. This has the advantage of being able to calc "Foo" == "Bar" etc.

When omitted the default argument is 1.

## EXAMPLE

To calculate the number of hours in a year:

    calc "365*24"

To then calculate the number of seconds in the year:

    calc "LR*60*60"

## NOTES

calc is a macro defined in `calc.emf`.

## SEE ALSO

.calc.result(5).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>