jwz - March 25th, 2008 [entries|archive|friends|userinfo]
jwz

  www.jwz.org
  userinfo
  archive
  rss

Links
[»| DNA (Log) (iCal) WebCollage (LJ) Mixtapes ]

Tue, 25-Mar-2008

I, for one, demand that our new robot overlords bring that beat back [Tue, 25-Mar-2008 4:22 PM]
[Tags|, , ]
[music |whatever whitebread trance crap is playing in this video]

International Dance Party with Radar Technology

This look like, how you say, "party time".

link13 comments   ·   post comment

Your tax dollars at work. No, really! [Tue, 25-Mar-2008 8:12 PM]
[Tags|, ]
[music |Scylla -- Get a Helmet]

The stretch of Brannan between 9th and Division is between me and many of my destinations, and for at least six years, it's had a very nasty collection of potholes: less potholes than long, thin chasms on the gap between the asphalt and the concrete. I've lost at least two bike tires to them over the years.

So, on Feb 27, I thought "what the hell", and emailed potholes@sfdpw.org saying, basically, "hey, how about patching those."

On or about Mar 15... THEY DID.

Maybe this is just a coincidence, but, damn. I almost wiped out from the shock of it alone!

link12 comments   ·   post comment

MOST-POSITIVE-BIGNUM [Tue, 25-Mar-2008 9:20 PM]
[Tags|, ]
[music |Throwing Muses -- Counting Backwards]

Hey kids, here's a story from the Unfrozen Caveman Files!

I was telling someone about about this the other day, and it's time that Google said something other than "Your search - most-positive-bignum - did not match any documents" so here it is.

Background:

In Common Lisp, there are two types of integers: small ones, which are what you expect; and "bignums", which the specification says should have no upper limit on their range. Fixnums are immediate values (not objects) and bignums are compound (allocated) objects. All the math functions work on either, promoting results to bignums as needed.

So, there is a constant called MOST-POSITIVE-FIXNUM, which is the largest representable "immediate" integer. C calls this MAXINT, and in a C world, it's generally 2^31-1. Because of the type bits on every word, in Lisp it's typically smaller than that. On TI Explorer Lisp Machines it was 2^24-1 (32 bit word, 7 bits of tag).

Here Comes the Dumb:

Well, I was poking around in the system's basement one day, and realized that their implementation of bignums did have an upper limit! A bignum was implemented as an array, with no facility to tack on a second array, so the limit was related to the size of the length field in the array header (instead of being limited by available memory).

So I went and consed up MOST-POSITIVE-BIGNUM.

I did this by carving out a chunk of memory of the proper size for the underlying array, filling it with the right pattern of ones, and slapping an appropriate type tag on the front so that the system would recognize it.

(These sorts of tricks are exactly the sort of things that Java goes out of its way to prevent you from doing, and that's part of why it's impossible to write efficient programs in Java. Whereas the whole Lisp Machine operating system was written in Lisp.)

Fun facts:

  • It is 1,223,146 decimal digits (that's 1.0e1223146).
  • The object representing it consumes 524 KB of RAM.
  • The largest known prime passed it in 1999.
  • If you add one to it, e.g.: (1+ MOST-POSITIVE-BIGNUM) you get zero. But it's a zero that consumes 524 KB, and is not = to 0.
  • If you ever tried to print it (for example, by having it be the return value in the debugger...) a TI Explorer would lock up in a tight loop in microcode, from which only a warm boot would recover. That microcode loop was trying to grind the number into decimal. That process took more than three days.
  • Printing it as a roman numeral took pretty much the same amount of time.

And finally, here's some code that doesn't run on any computer that has been manufactured in two decades.

(Coincidentally, it looks like I wrote this code eighteen years and four days ago. I guess I should have posted this on Friday.)

--More--(49%)  )

link38 comments   ·   post comment

navigation
[ viewing | Tue, 25-Mar-2008 ]
[ go | Previous Day|Next Day ]