Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java doesn't have unsigned shorts, bitmasks occur instead #14

Open
austinarrowsmith opened this issue Feb 10, 2021 · 1 comment
Open

Comments

@austinarrowsmith
Copy link

I think there might be an issue with some of the fields being read out / unmarshaled using .readShort(), as this results in high end shorts (>32k) being negative. This could cause a few issues with lookups of enumerations - if they were populated that high.

So far in various simulation tools, I've encountered issues with ElectronicEmitterPdu, EntityStatePdu and the classes used within (EntityID, etc) but I'm sure any part of the standard that references 2-bytes needs to be unsigned, so probably stored internally as an int that's masked (0xFFFF). Some are, but some aren't. Unsure on the lack of uniformity.

Raising this for further discussion on resolution or my use-case. :-)

@terry-norbraten
Copy link
Collaborator

terry-norbraten commented Nov 11, 2023

@austinarrowsmith, looking through the EntityID and EE PDU classes, I'm seeing the proper masking during unmarshalling (& 0xFFFF) occurring for unsignedShorts in the src. Do you have another a specific reference in the src for where this is not occurring?

@terry-norbraten terry-norbraten transferred this issue from open-dis/opendis7-java Nov 28, 2023
@brutzman brutzman changed the title Java doesn't have unsigned shorts Java doesn't have unsigned shorts, bitmasks occur instead Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants