Skip to content
This repository has been archived by the owner on Jun 26, 2019. It is now read-only.

LITTLE_ENDIAN Floats and Doubles are read as BIG_ENDIAN #15

Open
xcube16 opened this issue Feb 15, 2019 · 0 comments
Open

LITTLE_ENDIAN Floats and Doubles are read as BIG_ENDIAN #15

xcube16 opened this issue Feb 15, 2019 · 0 comments

Comments

@xcube16
Copy link

xcube16 commented Feb 15, 2019

https://github.com/flow/nbt/blob/7a1b6d986e6fbd01862356d47827b8b357349a22/src/main/java/com/flowpowered/nbt/stream/EndianSwitchableInputStream.java#L100-L122

As you can see, readInt() and readLong() take care of the endian ness, but readFloat() and readDouble() also try to take care of flipping the bytes around! This causes LITTLE_ENDIAN Floats and Doubles to be read as BIG_ENDIAN.

    public float readFloat() throws IOException {
        return Float.intBitsToFloat(readInt());
    }

    public double readDouble() throws IOException {
        return Double.longBitsToDouble(readLong());
    }

That should fix it.

If someone could sneak that into there next PR that would be nice! ;) Fixed in PR #16

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant