16bit code in Solaris?

By Paul Murphy, author of The Unix Guide to Defenestration

Psst, wanna free beer?

Ok, ignoring social costs and issues of credibility, all you need to do is wait for the opportunity to come up, and then sniff loudly about silly 16bit limitations in Solaris 9. Most people will tell you there aren't any, and they're right but you can still "prove" the suckers wrong.

When you bring up a large file in vi, it builds an index in /tmp (or whatever write space you specify in .exrc -- like this: set directory=/var/tmp except /var/tmp isn't such a great idea because thats also where recovery files go.)

That index cannot grow beyond 134,184,960 bytes - a 16-bit limitation from the old PDP11/70 days because this is the largest number that can be represented with 12 bits for the mantissa and 4 bits for the exponent (= ((2^12 - 1) * 2^15 ).

To show people the limit, start vi with a file bigger than half that in bytes and you'll get the "Tmp file too large" message when it fails to load completely. Then when you look at the size of the /tmp file it produced you'll see something like:

-rw------- 1 paul staff 134184960 Oct 8 12:29 Exswa46B

Et Voila! living "proof" of a 16bit limitation in Solaris 9.