Subject: Re: Help with using format control strings From: Erik Naggum <erik@naggum.no> Date: 16 Oct 2002 02:34:11 +0000 Newsgroups: comp.lang.lisp Message-ID: <3243724451319802@naggum.no> * Jon Allen Boone | Every CL implementation I've tried fails on this example [apparently | because the 0 needs to be single-quoted to make it a character?]. That example is one of the very small number of actual bugs in the standard. Note, however, that examples are not authoritative in any way and are not formally part of the standard. This is an editorial decision I support wholeheartedly. Examples are generally a bad thing outside of carefully controlled educational settings (as tutorials) because people just as easily learn wrong things from them as the intended purpose if they are not sufficiently guided in what they are supposed to learn. In this case, you have not read the specification, but have "believed" the example. There is really nothing more important to say on this than that this is the wrong order of preference. The right order of preference in a specification and especially a standard is the normative clauses, then the normative clauses, then the normative clauses again just to make sure, and only if you got the point from the normative clauses, you can look at the non-normative clauses, in which you should report anything not immediately reconcilable with the normative clauses as a mistake in the standard, not with your understanding of it. | This came up in some exercises I'm working through in a new book, | _Hacker's Delight_ by Henry S. Warren, Jr. [ISBN 0-201-91465-4] which is | in spirit a follow-on to the 1972 MIT Research memo HAKMEM [according to | Guy L. Steele, Jr., who wrote the Foreword]. Thanks for the reference. I had somehow missed this book. | Rather than just memorize the formulas, I am attempting to convince | myself that they are correct by looking at the binary representation of | numbers and performing the operations in my head. So, I wanted to use | 32-bit padded binary representation to print out the numbers. Since you are on the topic of cute hacks, try (format <stream> "~41,'0,' ,4:B" (dpb <integer> (byte 32 0) (ash 1 32))) This also solves your negative 32-bit integer printing problem neatly. Exercise: Explain why. :) -- Erik Naggum, Oslo, Norway Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.