The OpenD Programming Language

convertNormInt

Convert values between normalized integer types.

@safe pure nothrow @nogc
To
convertNormInt
(
To
From
)
(
From i
)
if ()

Examples

// unsigned -> unsigned
static assert(convertNormInt!ubyte(ushort(0x3765)) == 0x37);
static assert(convertNormInt!ushort(ubyte(0x37)) == 0x3737);
static assert(convertNormInt!uint(ubyte(0x35)) == 0x35353535);

// signed -> unsigned
static assert(convertNormInt!ubyte(short(-61)) == 0);
static assert(convertNormInt!ubyte(short(0x3795)) == 0x6F);
static assert(convertNormInt!ushort(byte(0x37)) == 0x6EDD);
static assert(convertNormInt!uint(byte(0x35)) == 0x6AD5AB56);

// unsigned -> signed
static assert(convertNormInt!byte(ushort(0x3765)) == 0x1B);
static assert(convertNormInt!short(ubyte(0x37)) == 0x1B9B);
static assert(convertNormInt!int(ubyte(0x35)) == 0x1A9A9A9A);

// signed -> signed
static assert(convertNormInt!short(byte(-127)) == -32767);
static assert(convertNormInt!short(byte(-128)) == -32767);
static assert(convertNormInt!byte(short(0x3795)) == 0x37);
static assert(convertNormInt!byte(short(-28672)) == -112);
static assert(convertNormInt!short(byte(0x37)) == 0x376E);
static assert(convertNormInt!short(byte(-109)) == -28123);

Meta