Numeric literals in other than base 10 - was Annoying octal notation
NevilleDNZ
nevillednz at gmail.com
Mon Aug 24 08:22:42 EDT 2009
On Aug 23, 9:42 pm, James Harris <james.harri... at googlemail.com>
wrote:
> The numbers above would be
>
> 0b1011, 0t7621, 0xc26b
Algol68 has the type BITS, that is converted to INT with the ABS
operator.
The numbers above would be:
> 2r1011, 8r7621, 16rc26b
"r" is for radix: http://en.wikipedia.org/wiki/Radix
The standard supports 2r, 4r, 8r & 16r only.
The standard supports LONG BITS, LONG LONG BITS etc, but does not
include UNSIGNED.
Compare gcc's:
bash$ cat num_lit.c
#include <stdio.h>
main(){
printf("%d %d %d %d\n",0xffff,07777,9999,0b1111);
}
bash$ ./num_lit
65535 4095 9999 15
With Algol68's: https://sourceforge.net/projects/algol68/
bash$ cat num_lit.a68
main:(
printf(($g$,ABS 16rffff,ABS 8r7777,9999,ABS 2r1111,$l$))
)
bash$ algol68g ./num_lit.a68
+65535 +4095 +9999 +15
Enjoy
N
More information about the Python-list
mailing list