Comparing 2 UInt64s in Lua for Null Value
I am trying to print "No Value" on certain 64bit nullable sentinel values for SBE protocols. Here is a code example:
-- Size: Cross Id
size_of.cross_id = 8
-- Display: Cross Id
display.cross_id = function(value)
-- Check if field has value
if value == 18446744073709551615 then
return "Cross Id: No Value ("..value..")"
end
return "Cross Id: "..value
end
-- Dissect: Cross Id
dissect.cross_id = function(buffer, offset, packet, parent)
local length = size_of.cross_id
local range = buffer(offset, length)
local value = range:le_uint64()
local display = display.cross_id(value, buffer, offset, packet, parent)
parent:add(cme_futures_ilink3_sbe_v8_7.fields.cross_id, range, value, display)
return offset + length, value
end
This script prints 18446744073709551615 for the null values. I know the 64 bit types have special handling. What is the cleanest method to handle this type?
What do you mean, "it prints 18446744073709551615 for the null values"? What do you expect it to print?