I couldn't find anything on the http://clojure.org/reader page, but someone
had just posted an example of notation for alternative bases.

It looks like you just enter <BASE>r<NUMBER>

user=> 2r1000
8
user=> 3r300
java.lang.NumberFormatException: For input string: "300"
user=> 3r200
18


Paul

On Sun, Mar 15, 2009 at 10:53 PM, Aaron Brooks <aa...@brooks1.net> wrote:

>
> Rather than going to the horrible effort </irony> of looking up to see
> if Clojure had support for binary notation, I had a Clojure prompt so
> I just tried it and got semi-surprising results:
>
> user=> #b010001
> java.lang.Exception: No dispatch macro for: b
> 4097
>
> I'm not surprised that Clojure complains of not knowing what manner of
> macro #b is but I was impressed (?) that it still yielded the correct
> value. Somewhere, deep in Clojure's little heart, it wants to do other
> bases.
>
> So, here's a request -- can we get macro dispatch for other base
> numbers? The CL notation is reasonable, already known and quite
> readable. Besides, Clojure tells me it /really/ /wants/ to... ;-)
>
> -Aaron
>
> On Fri, Mar 13, 2009 at 9:19 AM, David Sletten <da...@bosatsu.net> wrote:
> >
> >
> > On Mar 13, 2009, at 3:07 AM, Michael Wood wrote:
> >>
> >> This is pretty standard behaviour.
> >>
> >> On the other hand, it's not universal.
> >>
> >> sbcl:
> >>
> >> * 07
> >>
> >> 7
> >> * 08
> >>
> >> 8
> >>
> >
> > Common Lisp uses a separate syntax for binary/octal/hex literals. Legal:
> > #b1011, #o377, #xDEADBEEF, #36rZZZ (Base 36 anyone?)
> > Illegal:
> > #b2, #o8, #xQUICKSAND
> >
> > (Of course, #36rCLOJURE => 27432414842 :-) )
> >
> > Aloha,
> > David Sletten
> >
> >
> >
> > >
> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to