Literals/Integer: Difference between revisions

(→‎{{header|C}}: create C++ example)
Line 105:
>(= 727 #20r1g7)
T
</pre>
 
=={{header|D}}==
 
D besides hexadecimal, and octal bases has also binary base.
Additionaly you can use '''_''' to separate digits in
integer literals.
 
<lang D>
import tango.io.Stdout;
 
int main(char[][] args)
{
Stdout ("oct: ") (0777).newline;
Stdout ("bin: ") (0b01011010).newline;
Stdout ("hex: ") (0xBADF00D).newline;
Stdout ("dec: ") (1000000000).newline;
Stdout ("dec: ") (1_000_000_000).newline;
Stdout.newline;
Stdout (typeid(typeof(0))).newline;
Stdout (typeid(typeof(0u))).newline;
Stdout (typeid(typeof(0L))).newline;
Stdout (typeid(typeof(0uL))).newline;
Stdout (typeid(typeof(0LU))).newline;
Stdout.newline;
Stdout.formatln ("{:x}", 0xFEE1_BAD_CAFE_BABEuL);
return 0;
}</lang>
 
Output:
<pre>
oct: 511
bin: 90
hex: 195948557
dec: 1000000000
dec: 1000000000
 
int
uint
long
ulong
ulong
 
fee1badcafebabe
</pre>
 
Anonymous user