Literals/Integer: Difference between revisions

Added Quackery.
(Added 11l)
(Added Quackery.)
Line 1,644:
 
In Python 2.x you may also specify a <tt>long</tt> literal by adding an <tt>l</tt> or <tt>L</tt> (the latter form is preferred as the former looks like a "1") to the end (ex: <tt>574298540721727L</tt>), but this is optional, as integer literals that are too large for an <tt>int</tt> will be interpreted as a <tt>long</tt>.
 
=={{header|Quackery}}==
 
The default base for the Quackery compiler is decimal. This can be overridden for a single hexadecimal number with the building word (compiler directive) <code>hex</code> like this; <code>hex DEFACEABADFACADE</code>.
 
The default base can be overridden for a section of code using the compiler directive <code>now!</code> like this;
 
<lang Quackery>[ 2 base put ] now!
 
( The Quackery compiler now expects numeric literals to be in binary )
 
[ base release ] now!
 
( The Quackery compiler now expects numeric literals to be whichever
base they were previously. The default base is decimal. )</lang>
 
If a new compiler directive akin to <code>hex</code> is required, say to allow occasional octal literals in the form <code>octal 45</code>, the compiler can be extended like this;
 
<lang Quackery> [ 8 base put
nextword dup
$ '' = if
[ $ '"octal" needs a number after it.'
message put bail ]
dup $->n iff
[ nip swap dip join ]
else
[ drop
char " swap join
$ '" is not octal.'
join message put bail ]
base release ] builds octal ( [ $ --> [ $ )</lang>
 
=={{header|R}}==
1,462

edits