Scott David Daniels wrote:
Tim Roberts wrote:
My favorite notation for this comes from Ada, which allows arbitrary bases
from 2 to 16, and allows for underscores within numeric literals:

  x23_bin : constant :=  2#0001_0111#;
  x23_oct : constant :=  8#27#;
  x23_dec : constant := 10#23#;
  x23_hex : constant := 16#17#;
And mine is one w/o the base 10 bias:
    .f.123 == 0x123
    .7.123 == 0o123
    .1.1101 == 0b1101
That is, .<largest allowed digit>.<digits>
-- show the base by showing base-1 in the base.
I actually built this into "OZ," an interpretter.

Smalltalk uses "r" (for "radix"). If we also permit underscores:

    x23_bin =  2r0001_0111
    x23_oct =  8r27
    x23_dec = 10r23
    x23_hex = 16r17
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to