Are bitmasks safe for cross platform network replication?

Couldn’t think of a decent title but; I’d like to know if network replication is reliable cross platform (from say a console to smartphone to a pc) so that different devices can share the same multiplayer server. I’m guessing there may be some overhead since floats alone would be different between cpu’s, and if the above is safe does that mean that using byte bitmasks (for bit flags) is reliably safe as well? Is there any pitfalls to watch out for?

Float representation isn’t different between CPUs (it’s all IEEE 754), math on floating operations can be due to rounding differences (particularly if you use SIMD, lots of times Intel will round up where AMD will round down on ties) and just generic error accumulation.

The only way bitmasks would be different is if you are communicating between two systems that have a different endian order, but I’m struggling to think of any recent system now that isn’t little endian. Macs were the big hold out but even they’ve swapped over now.

I’ll have to write tests for this thank you. A lot of what i read about bitmasks was mentioned by devs that work on embedded software. But I doubt bit fields would have a lot of problems since it’s just one bit at a time your working with. Meh will have to test. And about floats that actually surprises me. Because if that’s true, then one can assume floats are safe to transport just not safe to calculate with if one wishes to assume identical results on both clients. Still this is good news and gives me things to think about thank you. I’m just writing some plugin code and wish to make it as network friendly as possible. OHHH but the main thing I’m wondering about. How well does ue4 generally handle multiplayer when having different devices of different makes connecting with one another? Any idea how many tried to network say… An xbox game and with it’s pc counterpart?

…why would you use a float for a bitmask?! That’s so weird. Just use an int32. It’s way easier and safer to do bitmask comparisons.
If you’re worried about cross platform stuff, the only possible gotcha could be the big endian vs little endian ordering of bytes, but if you already know which platforms you’re going to deploy to ahead of time, you would already know if that’s going to be an issue or not.

No the bitmask is just on a byte. I was curious about how floats reacted to the situation to, since I’m trying to make plugins that should work well cross platform and with networking, ideally where different devices can safely share data with each other.

Use int32. It’s cross platform compatible. It’s far easier to compare an int32 bitmasked value to 63 (11 1111) than it is to compare a float to whatever 11 1111 might be in float. It’s also much easier to punch in on a calculator. It’s pretty much the industry standard to use integers for bitmasking.

Again, as long as the Endian-ness of the platforms being connected is the same, there’s no issues. We have IEEE standards for a reason. :slight_smile:

Even a float is just a simple array of bits, it’s only when different CPUs operator on those bits that you can get divergent behaviors (again, that mainly happens in SIMD code - SSE vs NEON for example). 99% of the time, you’re fine. The main issue with cross platform play isn’t a technical issue - it’s a platform holder issue / gameplay fairness issue.

Of which the latter two problems can be gotten around thank you. And for Slayer again i’m not talking about using floats for bitmasks. That wasn’t mentioned. Or at least not intended. It’s just another form of data I was concerned about, and am a bit surprised because I was expecting phones for example to even store floats different somehow since the ones designing them would want to make some kind of shortcuts. But glad this is cleared up. Thank you.