BASECALC

Section: User Commands (1)
Updated: August 15, 1989
Index Return to Main Contents
 

NAME

basecalc - programmer's calculator  

SYNOPSIS

basecalc [-s] [ -x | -h | -d | -o | -b] [-background colorname] [-bg colorname] [-display servername] [-fg colorname] [-foreground colorname]  

OPTIONS

-s
Begin in unsigned mode.
-x
Begin in hexadecimal mode.
-h
Begin in hexadecimal mode.
-d
Begin in decimal mode (the default).
-o
Begin in octal mode.
-b
Begin in binary mode.
 

DESCRIPTION

basecalc is a simple programmer's calculator written using Xlib that is especially useful for binary math and for converting between binary, decimal, octal, and hexadecimal.

The long horizontal window along the top of the calculator is the display, in which the values punched on the calculator and results are displayed. The digits (0-9) and letters (A-F) in the left-hand portion of the calculator keypad are for entering values. The top row of the right-hand portion of the keypad is for base selection. These can be used either to set the current base of calculations, or to convert a value between bases. Only one of the base indicators is highlighted at a time.

Only valid numbers in the current base are allowed to be entered. Valid pads are black while invalid ones are light gray (by default). When a pad is triggered by pressing a pointer button, it flashes white, and the operation or value indicated by the pad is executed if the pointer button is released in the same pad. The pad also responds to the pointer entering or leaving the window while a pointer button is pressed.

The calculator also operates from the keyboard. Numbers, letters, and special characters can be typed in to represent all the functions. The Backspace key performs the Clear Entry (CE) function.

This calculator does not have a Reverse Polish Notation (RPN) mode.

Here is the list of available functions and how they are used.

All operations work in all bases. You may shift bases at any point in any calculation. The last of any series of consecutive operators pressed will be acted upon.

+, -, *, /
Normal addition, subtraction, multiplication, and division. A number is entered, then one of these operators, then another number, and finally the equals sign, Enter key, or any operator. The result will then be displayed in the window. If the last character entered was an operator, you can continue specifying numbers and operators in alternation.
| , &
AND and OR. Used just like the addition operator. The "|" and "&" symbols on the keyboard trigger this function.
<< , >>
Shift Left and Shift Right. Used just like the addition operator. Enter the number to be shifted, then the ">>" or "<<" pad (or the ">" or "<" keys), and then the number of bits to shift the number, followed by the "=" or Enter key.
^
Exclusive OR. Used just like the addition operator. Sets all bits that are in either number but not both. Available from the ^ (caret) key.
%
Mod (remainder after division). Used like the addition operator. Available on the % (percent) key.
`
Change sign. This is a unary operator, since it performs its function immediately on the current contents of the display. Its results depend on whether the calculator is in signed or unsigned mode. If in unsigned mode, the result is the unsigned equivalent of a negative number. This function is available from the left single-quote key.
~
Two's complement. This is a unary operator. It changes all the bits in the value.
CE
Clear Entry. Erases the last value entered. The Backspace key also performs this function.
CD
Clear Digit. Erases the last digit entered.
CA
Clear All. Clears all operator and value registers.
U or S
Unsigned or Signed. Specifies whether all other operations should be performed in signed or unsigned mode.
=
Compute. The Return key also performs this function.
 

AUTHOR

Alan Greenspan of Stellar Computer. Modified for publication as an Xlib programming example by Adrian Nye of O'Reilly and Associates, Inc.  

BUGS

One font, one size.


 

Index

NAME
SYNOPSIS
OPTIONS
DESCRIPTION
AUTHOR
BUGS

This document was created by man2html, using the manual pages.
Time: 23:32:15 GMT, February 06, 2023