~ <type> => <type> for all integer types in D, however ~ <type> => int for small integer types in C. This is a source of silently different behavior between D and C at least in unsigned integer types. example: // test.d import std.stdio; void main(){ ushort x = 0xffff; writefln("%08x", ~x+1u); } // test.c #include <stdio.h> void main(void){ unsigned short x = 0xffff; printf("%08x", ~x+1u); }
Documented the difference.
https://github.com/dlang/dlang.org/commit/4cd3f38bbabdde30b280738dab4f4184c06f05f9
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル