KONV by Jesper Blauendahl July 2002 This is my first program for the TI-89. It has been developed using TIGCC IDE and compiles with the default settings. I'm very interested in feedback, bug reports, and suggestions. These can be submitted to jbla00@kom.auc.dk I) Introduction II) Installation III) How to use KONV I)Introduction -------------- KONV is a helpful utility that displays 16 bit integer numbers in the bases: binary, decimal and hexadecimal. It also displays an integer interpreted as two’s compliment signed integer and as two’s compliment signed fractions. In 16 bit integer machines numbers are stored as 16 binary digits ( 0’s and 1’s), but they can be difficult to understand because we normally use numbers in base 10 (decimal numbers). Another more compact representation is in hexadecimal, that I base 16, is also commonly used but can be equally difficult to interpret. Therefore this program. It displays the same number in the three most commonly used bases, for example: --------------------------------------------- | Binary | base 2 | 10110010 01101110 | --------------------------------------------- | Decimal | base 10 | 45678 | --------------------------------------------- | Hexadecimal | base 16 | B26E | --------------------------------------------- Unsigned 16 bit integers can represent values in the range 0 – 65535 (decimal), but the binary numbers can also be interpreted at signed values using two’s compliment representation. In this interpretation MSB is used to indicate the sign (0 equals + and 1 equals -) giving the range -32768 – 32767 (decimal). In the above mentioned representations/interpretations the numbers are integers. This can be thought of as if the decimal point is placed after LSB, for example: 00011001 01101110. thus representing the value 6510 when interpreted two’s compliment signed integer. In this interpretation the digits after the sign bit represent decreasing powers of 2 starting at 2^(14) and ending at 2^(0). The decimal value of the binary number above can be calculated as follows (the width of your text viewer should be wide enough to contain all of the next line, otherwise it will look very odd): 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0*2 +0*2 +1*2 +1*2 +0*2 +0*2 +1*2 +0*2 +1*2 +1*2 +0*2 +1*2 +1*2 +1*2 +0*2 = 6510 beware: negative numbers are not evaluated in the same way. Another interpretation of the same binary number is two’s compliment signed fractions (widely used in digital signal processing) where MSB is used as sign bit and the decimal point is placed right after the sign: 0.0011001 01101110 representing the value 0.198669 (rounded to 6 decimals). The digits after the sign bit represent decreasing powers of 2 starting at 2^(-1) and ending at 2^(-15). The decimal value of the binary number above can therefore be calculated as (the bits with 0’s have been omitted): -3 -4 -7 -9 -10 -12 -13 -14 1*2 +1*2 +1*2 +1*2 +1*2 +1*2 +1*2 +1*2 = 0.198669 beware: negative numbers are not evaluated in the same way. The range of this interpretation is (-1) – (1-2^(-15)). KONV displays all five representations/interpretations simultaneously (Unsigned integer, signed integer, signed fractional, binary and hexadecimal). For example: Unsigned Int 6510 Signed Int 6510 Fractional 0.198669 Binary 00011001 01101110 Hexadecimal 196E The format of the number in the line labels Fractional is determined by the settings in the MODE-dialog (NORMAL, SCIENTIFIC, ENGINEERING). Also the number of decimals is set here. II) Installation ---------------- Simply transfer konv.89z to your calculator using a linkprogram. After that KONV can be started by typing konv() and pressing ENTER. III) Usage ---------- After starting KONV the screen will display five lines labelled: Unsigned Int, Signed Int, Fractional, Binary and Hexadecimal. Unsigned Int will be marked by a black box indicating the entry point. Numbers can be typed in any of the five formats by moving the marker to the desired entry point using the UP and DOWN arrows. Once the marker is positioned entering a number can be initiated by pressing ENTER or just by starting to type the number. To display the different interpretations of the number press ENTER. The ESC button is used to quit the program. Pressing ESC while typing a number causes the typing function to be terminated, returning 0 to the converter. Keys: UP-/DOWN-arrow: Moves the marker to the desired location. ENTER: Starts and stops the typing of a number to be converted. Backspace: guess ESC: Exits the program (while typing it only terminates the typing function) Numbers can be entered using the keys: ‘0’ – ‘9’, ‘a’ – ‘f’ (hex only), ‘.’ (fractional only), ‘EE’ (fractional only) and ‘(-)‘ (signed int and fractional only).