In article <
2022Jun2...@mips.complang.tuwien.ac.at>,
Anton Ertl <
an...@mips.complang.tuwien.ac.at> wrote:
>albert@cherry.(none) (albert) writes:
>>ciforth went there. As soon as the base is not decimal, the exponent
>>sign becomes _.
>...
>>The _ is algol68 compatible, going as far as 5F.
>
>That's unfortunate, because _ is a common digit group separator, not
>just in Ada, C#, D, Haskell, Java, Kotlin, OCaml, Perl, Python, PHP,
>Ruby, Go, Rust, Julia, and Swift
Python?
~$ echo aap=123456E1 | python
~$ echo aap=1234_56E1 | python
File "<stdin>", line 1
aap=1234_56E1
^
SyntaxError: invalid syntax
Fortunately floating point is a loadable extension in ciforth:
: XC BASE @ $0A = IF &E ELSE &_ THEN ; \ Exponent character
(line 2 in screen 250) is easily changed to
: XC BASE @ $0A = IF &E ELSE &~ THEN ; \ Exponent character
I wished that that grouping was applied to the 16 digit number that
I must type in to prolong my prepaid. For ease of reading the space
suffice largely. It can be used this way in Algol68, because white
space has no meaning in Algol68, except in strings.
>> Base 0x40 is useful, because
>>fp numbers can be represented exactly.
>
>If you want easy conversion to binary FP numbers, binary, octal, hex
>or base 32 will do, no need for base 64. The way other languages
>(apparently starting with C99) seem to have standardized on is hex
>mantissa digits, "p" (instead of "e") to start the exponent, and
>decimal exponent digits.
32 is 5 bits, 64 is 6 bits. Most Forthers will gladly accept the 16%
save in storage for virtually no effort:
0x40 BASE !
The Forth way is simple. All digits have the same BASE.
Accepting E as the exponent sign is a misguided compatibility
with FORTRAN. Using _ (or ~) from the start had been much simpler.
If you must be compatible with Ada, then you must jump through hoops.
It can't be helped, but ascii representation of fp Forth numbers
can be painless.
>
>- anton