public static void encode ( float value , byte [ ] dst , int dstOffset ) { int bits = Float . floatToIntBits ( value ) ; bits ^= ( bits < 0 ) ? 0xffffffff : 0x80000000 ; dst [ dstOffset ] = ( byte ) ( bits >> 24 ) ; dst [ dstOffset + 1 ] = ( byte ) ( bits >> 16 ) ; dst [ dstOffset + 2 ] = ( byte ) ( bits >> 8 ) ; dst [ dstOffset + 3 ] = ( byte ) bits ; }
Encodes the given float into exactly 4 bytes .