Skip to content

Add support for multiple bases to Prefix. #57

Description

@python-processing-unit

Add support for multiple bases in INT and FLT to Prefix.

Each number (INT or FLT) literal MUST be determined by a base prefix.

The following base prefixes are valid for number literals:

  • 0b = Binary literals consist of 0-1
  • 0o = Octal literals consist of 0-7
  • 0d = Decimal literals consist of 0-9
  • 0x = Hexadecimal literals consist of 0-9&A-F
  • 0t = Duotrigesimal (base 32) literals consist of 0-9&A-V
  • 0c = Base 58 literals consist of 1-9&A-H&J-N&P-Z&a-k&m-z
  • 0s = Base 64 literals consist of 0-9&A-Z&a-z&+_
  • 0rNN = Base NN. NN is two decimal digits, smaller than or equal to 64. Literals consist of the same set as base 64, only limited to those smaller than the base.

Numbers MUST NOT have a base less than decimal 2 or greater than decimal 64. If an operation (either with 0rNN or CONVERT) would produce such a number, it MUST error.

The output of a mathematical operation uses the highest base present in the operands.

The sign (- or nothing) MUST appear before the base prefix.

FLT infinities and NaN do not have a base specified with a prefix, and are considered base NaN.

Conversion of a number to a STR (including in PRINT) MUST represent the number in it's base, with the base prefix included.

Add new operator INT|FLT: CONVERT(INT|FLT: num, INT: base). Convert num to base base. If num was an INT that can not be represented precisely in base, keep it as an INT anyway. Add new operator INT: BASE(INT|FLT: num). Return the base of num.

BAND, BOR, BXOR, SHL, and SHR only accept binary INT.

Numbers remain otherwise the same.

Update both the implementation and the specification.

Metadata

Metadata

Labels

documentationImprovements or additions to documentationenhancementNew feature or requesthardNot recommended for beginners. Will take significant effort to complete.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions