diff --git a/docs/source/programming.rst b/docs/source/programming.rst index a8cb08a26..b69befb71 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -229,7 +229,7 @@ Integers ^^^^^^^^ Integers are 8 or 16 bit numbers and can be written in normal decimal notation, -in hexadecimal and in binary notation. +in hexadecimal and in binary notation. You can use underscores to group digits to make long numbers more readable. A single character in single quotes such as ``'a'`` is translated into a byte integer, which is the PETSCII value for that character. @@ -260,6 +260,8 @@ This saves a lot of memory and may be faster as well. Floating point numbers ^^^^^^^^^^^^^^^^^^^^^^ +You can use underscores to group digits to make long numbers more readable. + Floats are stored in the 5-byte 'MFLPT' format that is used on CBM machines. Floating point support is available on the c64 and cx16 (and virtual) compiler targets. On the c64 and cx16, the rom routines are used for floating point operations, diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index b887a3dd1..04f80c1d7 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -399,6 +399,10 @@ Note that ``%`` is also the remainder operator so be careful: if you want to tak of something with an operand starting with 1 or 0, you'll have to add a space in between. Otherwise the parser thinks you've typed an invalid binary number. +**digit grouping:** for any number you can use underscores to group the digits to make the +number more readable. Any underscores in the number are ignored by the compiler. +For instance ``%1001_0001`` is a valid binary number and ``3_000_000.99`` is a valid floating point number. + **character values:** you can use a single character in quotes like this ``'a'`` for the PETSCII byte value of that character. diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 8898dd422..2f8247868 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,8 +2,6 @@ TODO ==== -- document underscores in numeric literals for grouping - - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 .... ... diff --git a/syntax-files/IDEA/Prog8.xml b/syntax-files/IDEA/Prog8.xml index 145022b68..af5abf0b0 100644 --- a/syntax-files/IDEA/Prog8.xml +++ b/syntax-files/IDEA/Prog8.xml @@ -5,7 +5,7 @@