
co.nstant.in.cbor.decoder.SinglePrecisionFloatDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cbor Show documentation
Show all versions of cbor Show documentation
Java implementation of RFC 7049: Concise Binary Object Representation (CBOR)
The newest version!
package co.nstant.in.cbor.decoder;
import java.io.InputStream;
import co.nstant.in.cbor.CborDecoder;
import co.nstant.in.cbor.CborException;
import co.nstant.in.cbor.model.SinglePrecisionFloat;
public class SinglePrecisionFloatDecoder extends AbstractDecoder {
public SinglePrecisionFloatDecoder(CborDecoder decoder, InputStream inputStream) {
super(decoder, inputStream);
}
@Override
public SinglePrecisionFloat decode(int initialByte) throws CborException {
int bits = 0;
byte[] symbols = nextSymbols(4);
bits |= symbols[0] & 0xFF;
bits <<= 8;
bits |= symbols[1] & 0xFF;
bits <<= 8;
bits |= symbols[2] & 0xFF;
bits <<= 8;
bits |= symbols[3] & 0xFF;
return new SinglePrecisionFloat(Float.intBitsToFloat(bits));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy