Wheels within wheels...
For me, this is a development tool for a development
tool for the
ultimate software in development. To add to the irony,
this pet was
spawned by its own development tool. It seems comical
at times, but,
very often, the easiest way to test the worth a complicated
algorithm
is with a somewhat less complicated algorithm... Think
about it: even
if you really _do_ know how to build a foundry (few
do (grin)), in
isolation you would have to build a forge before you
could have any
hope of making the tools you would need to make a foundry...
But: this is a reasonably useful tool for everyday use as well.
Like everyone in the universe of 'user-friendly' computing,
I am
awash in hexadecimal numbers. The projects I'm working
on make heavy
use of some clever and oblique fixed-point encoding
schemes: the
FOND unit and the Fixed and Fract formats. I am really,
really sick
of converting numbers into and out of these formats,
hence Hex Key.
What Hex Key does is this: it presents a dialog into
which you can
enter either decimal or hexadecimal numbers, selectable
by radio
button. After you hit "Okay", or the return
or enter keys, the
numbers will be converted to the appropriate values
in the
alternative number formats. In other words, if you enter
a hex value,
the number will be converted to its appropriate form
in FOND, Fixed
and Fract decimal. If you enter a decimal number, it
will be shown in
FOND, Fixed and Fract hex. Where a number falls outside
the range of
the format, the text "N/A" is shown, so you
don't act upon a bogus
number. For convenience, seven other formats are shown:
signed and
unsigned longs, shorts and bytes are shown for reference
(with
decimal values rounded toward zero), and the ASCII characters
are
shown for values that fall within the ASCII range.
Decimal numbers can be entered in floating point form
(necessarily).
Hexadecimal must be entered as unsigned integers. Spaces
are allowed,
so you can Paste from a hex editor. It is not necessary
to format hex
numbers as "0xFF71", although you can if you
like.
That's really it, honest. CMD-C, CMD-X and CMD-V work,
but their
respective menu items are disabled because this really
_is_ a dialog,
and we're obeying the rules. Hex Key is compatible with
both Systems
6 and 7, is 32-bit clean and multi-finder aware. It
does not,
however, feature the sleek and understated Movado Museum
watch
cursor.
Number formats...
FOND: The Apple FOND resource uses a two-byte short
integer to
represent font metrics (e.g., ascent, descent, leading,
widths, and
kerns). The format of this number is four bits representing
the
signed integer number and 12 bits representing the fractional
part.
So, for example, the hex integer FF71 unpacks to -0.035
decimal.
Apple FOND units can range from -8.000 to 8.000. In
common parlance
1.000 is used refer to the em-square, so most FOND values
will fall
within the range of -1.000 to 1.000. (Why is that so?:
The Mac
toolbox multiplies the FOND unit times the point size
used to get the
actual numbers to feed to QuickDraw; the FOND unit expresses
font
metrics for a hypothetical 1 point type size).
Fixed: For PostScript, Adobe uses a format called 'Fixed',
which is
the same as the Apple data type 'Fixed', itself frequently
used in
QuickDraw. A Fixed is a four-byte long integer, with
the most
significant 16 bits representing the signed integer
and the remaining
16 bits representing the fraction. Fixed units can therefore
range
from -32768.000000 to 32768.000000.
Fract: The Fract is another Apple number format used
for QuickDraw. A
Fract is a four-byte long integer, with the most significant
2 bits
representing the signed integer and the remaining 30
bits
representing the fraction. Fracts can range from -2.000000000
to
2.000000000.
Because these number formats are so easy to confuse,
Hex Key displays
their scope at startup.
Who needs it...?
If you need it, you know. If you spend a lot of time
staring
glassy-eyed at FONDs in ResEdit, you need it. If you
read a lot of
PostScript, you need it. If you need to compare KernEdit
numbers to
their hex equivalents, you need it. If none of this
means anything to
you, you don't need it (grin).
Very Best,
Greg Swann
8/1/98
This page was created using TextToHTML. TextToHTML is a free software for Macintosh and is (c) 1995,1996 by Kris Coppieters