Data types returned from operators (signed vs unsigned integer)

Imported from previous forum

I have been in process of converting my trading system to using the FAST engine and am coming across some recurring bugs.

Can someone please clarify if operations such as the delta operation will return signed or unsigned integers? Does the operation always return the same data type as that which it is being used upon?

Shek,

the short answer is yes (if I have understood your questions)

As an FAQ response for other readers:

The delta value transferred is always signed even if the field is unsigned (this is logical, otherwise it would only be possible to increase the value of a field). [section 6.3.7]

Let’s assume that you have an unsigned field ‘x’ and let’s further assume that we are encoding three values [100, 120, 115].

We need to keep track of three quantities:
base - the previous value
wire - the delta quantity transferred on the wire
data - the data value for field ‘x’

Both the encoder and decoder keep track of the ‘base’ value.

The encoder calculates ‘wire = data - base’.
It then updates base; ‘base = data’.

The decoder calculates ‘data = base + wire’.
It then updates base; ‘base = data’.

When we start the base value is zero [section 6.3.7.1].

data=100 => base=0 + wire=100 => 100
data=120 => base=100 + wire=20 => 120
data=115 => base=120 + wire=-5 => 115

So, transferring [100, 120, 115] using delta coding produces the wire values [100, 20, -5]

The same procedure is used for signed integers with the difference that data values can take negative values in the signed case.

Hope this helps,
Rolf

Can someone please clarify if operations such as the delta
operation will return signed or unsigned integers?

Does the operation always return the same data type as that
which it is being used upon?

Good answer. Just in case this is the sort of thing that is driving someone nuts, though, I believe the right section is 10.7.1 (although it should have been 6.3.7).

Shek,

the short answer is yes (if I have understood your questions)

As an FAQ response for other readers:

The delta value transferred is always signed even if the field is
unsigned (this is logical, otherwise it would only be possible to
increase the value of a field). [section 6.3.7]

Let’s assume that you have an unsigned field ‘x’ and let’s further
assume that we are encoding three values [100, 120, 115].

We need to keep track of three quantities: base - the previous value
wire - the delta quantity transferred on the wire data - the data value
for field ‘x’

Both the encoder and decoder keep track of the ‘base’ value.

The encoder calculates ‘wire = data - base’. It then updates base;
‘base = data’.

The decoder calculates ‘data = base + wire’. It then updates base;
‘base = data’.

When we start the base value is zero [section 6.3.7.1].

data=100 => base=0 + wire=100 => 100 data=120 => base=100 + wire=20 =>
120 data=115 => base=120 + wire=-5 => 115

So, transferring [100, 120, 115] using delta coding produces the wire
values [100, 20, -5]

The same procedure is used for signed integers with the difference that
data values can take negative values in the signed case.

Hope this helps, Rolf

Can someone please clarify if operations such as the delta operation
will return signed or unsigned integers?

Does the operation always return the same data type as that which it
is being used upon?