public static void encodeTimestamp ( byte [ ] array , int pointer , double timestamp ) { // Converts a double into a 64-bit fixed point for ( int i = 0 ; i < 8 ; i ++ ) { // 2^24, 2^16, 2^8, .. 2^-32 double base = Math . pow ( 2 , ( 3 - i ) * 8 ) ; // Capture byte value array [ pointer + i ] = ( byte ) ( timestamp / base ) ; // Subtract captured value from remaining total timestamp = timestamp - ( unsignedByteToShort ( array [ pointer + i ] ) * base ) ; } // From RFC 2030: It is advisable to fill the non-significan't // low order bits of the timestamp with a random, unbiased // bitstring, both to avoid systematic roundoff errors and as // a means of loop detection and replay detection. array [ 7 ] = ( byte ) ( Math . random ( ) * 255.0 ) ; }
Encodes a timestamp in the specified position in the message