Search code examples
stringnumbersradix

string representation of numeric literals in radices other than 2, 10, 16?


C has the convention where 0x____ means a hexadecimal literal number, and I've seen 0b____ for binary literal number (most notably in Java 7 Project Coin).

Is there anything out there for representing arbitrary radices? (up to base 36)

(e.g. 36rA0CZ or A0CZr36 with the 36r representing the radix and A0CZ representing the literal as expressed in that radix, in this case equal to the decimal number 467027)

I need to pick something for a program I'm working on, and would rather use an existing convention.


Solution

  • Smalltalk uses the convention you show in your question (radixrnumber). Zsh uses radix#number. VHDL uses radix#number#. Overall, the syntax you show is reasonable, and I do not believe there is a single notation that is standard or quasi-standard.