number-to-i32

xod/bits/number-to-i32

Converts number to a 32-bit signed integer presented as 4 bytes. An input for the the conversion should be between -2147483600.00 and 2147483600.00.
number-to-i32
@/number-to-i32
Converts number to a 32-bit signed integer presented as 4 bytes. An input for the the conversion should be between -2147483600.00 and 2147483600.00.
INnumber
number-to-i32
IN
B2
B3
B1
B0
B0byte
Least significant byte
B1byte
B3byte
Most significant byte
B2byte

C++ implementation

node {
    void evaluate(Context ctx) {
        int32_t val = getValue<input_IN>(ctx);
        uint8_t b3 = (val >> 24);
        uint8_t b2 = (val >> 16);
        uint8_t b1 = (val >> 8);
        uint8_t b0 = val;
        emitValue<output_B0>(ctx, b0);
        emitValue<output_B1>(ctx, b1);
        emitValue<output_B2>(ctx, b2);
        emitValue<output_B3>(ctx, b3);
    }
}

Tabular tests

INB3B2B1B0
-15999999.00FFh0BhDCh01h
15999999.0000hF4h23hFFh
255.0000h00h00hFFh
32767.0000h00h7FhFFh
-32767.00FFhFFh80h01h