On 10/05/2018 21:18, bartc wrote:
On 10/05/2018 19:51, Chris Angelico wrote:
On Fri, May 11, 2018 at 4:31 AM, bartc <b...@freeuk.com> wrote:
   2x100  (4)   Binary
   3x100  (9)   Ternary
   4x100  (16)  Quaternary
   5x100  (25)  etc
   6x100  (36)
   7x100  (49)
   8x100  (64)  Octal
   9x100  (81)
   ...           (Not implemented 11x to 15x, nor 10x or 16x)
   0x100  (256) Hex

YAGNI much? How often do you need a base-9 literal in your code??

I've just found out these also work for floating point. So that:

  a := 8x100.5
  print a

gives 64.625 in decimal (not 64.5 as I expected, because .5 is 5/8 not 5/10!). Exponent values are octal too, scaling by powers of 8.

I tried it in Python 3 (0o100.5 - I find that prefix fiddly to type actually as I have to stop and think), and it seems to be illegal.

Based floating point literals may be unusual, but bear in mind that in decimal, some values may not be represented exactly (eg 0.1). I believe that in base 2, 4, 8 or 16, any floating point literal can be represented exactly, at least up the precision available.


--
bartc


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to