@SuppressWarnings("unused") public Float getLongitude() { return getDecodedValue( () -> longitude, value -> longitude = value, () -> Boolean.TRUE, () -> FLOAT_DECODER.apply(getBits(40, 58)) / 10f); }
@Test public void canConvertToUnsignedInteger() { // 1011100101011100011011001111 -> -123.450533333333 assertEquals(Float.valueOf(0), FLOAT_DECODER.apply("0000000000000000000000000000")); assertEquals(Float.valueOf(1), FLOAT_DECODER.apply("0000000000000000000000000001")); assertEquals(Float.valueOf(0), FLOAT_DECODER.apply("1111111111111111111111111111")); assertEquals( -123.450533333333f, FLOAT_DECODER.apply("1011100101011100011011001111") / 600000f, 1e-16); // 74070320 assertEquals(37.21113f, FLOAT_DECODER.apply("001010101001010110110010100") / 600000f, 1e-16); // 181 degrees (0x6791AC0 hex) // Decoder.convertToUnsignedInteger(bitString) // 91 degrees (0x3412140 hex) // Course over ground will be 3600 (0xE10) }