[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Engineering numbers ..



I am an engineer using LISP for simulations and things - LISP is very
flexible and I enjoy using it. Almost everything I want to do can be
done in LISP.

One thing that is hard to do is (+ 3.45k 4.56k) = 8.01k

You see electrical engineers think of k, u, p n as scaling factors for
numbers (remember those HP calculators that had engineering mode where
the exponent was always a multiple of 3?)

This is not a crazy request. One of the advantages of LISP in a
simulator is that you can build macros and turn LISP itself into the
simulator you need to get the job done. I sit in a LISP listener or
LISP (Emacs) editor and run simulations. Other simulators know about
engineering numbers [all spice variants do, and some simulators even know
about units too - (/ 3.4v 0.1mA) => 34kohms]. 

I can find no way in common lisp to make the reader see 3.4k as a
number. I know about the # macro and escaping to user code in the
reader but its not acceptable to prefix everything with #.

A long time ago someone hacked the symbolics read table stuff for me to
give me an EE syntax (similar to the CL or ZL syntax option on the Smbx
machines) but this only works on the Smbx machine (and that was at my
last place of employment and I no longer have access to that code).

What this mail is about boils down to 2 things:

1) Does anyone know how to get Common Lisp to read engineering numbers?
(and print them - although this is easier)

2) If not, would someone responsible for new feature in CL please
consider some mechanism to allow this.

Could this be a simple as defining a *readhook* like the *evalhook*?
[Can *evalhook* do this job for me?]

--------------------------------------------------------------------------------
Martin Mallinson                                martin@cmt.dialnet.symbolics.com

Crimble Micro Test Inc.                              
5 Tomahawk Drive                                Phone: 508 667 9405
Billerica MA 01821                              Fax:   508 667 0192
--------------------------------------------------------------------------------