dlang-book/book/02-основные-типы-данных-выражения/src/chapter-2-3-10/app.d

15 lines
424 B
D
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import std.stdio;
void main()
{
int a = -1; // То есть 0xFFFF_FFFF
int b = a << 1;
assert(b == -2); // 0xFFFF_FFFE
writeln("a = ", a, "; b = ", b, ';');
int c = a >> 1;
assert(c == -1); // 0xFFFF_FFFF
writeln("a = ", a, "; c = ", c, ';');
int d = a >>> 1;
assert(d == +2147483647); // 0x7FFF_FFFF
writeln("a = ", a, "; d = ", d, ';');
}