All pastes #215786 Raw Edit

Untitled

public java v1 · immutable
#215786 ·published 2006-10-22 20:22 UTC
rendered paste body
	private static byte[] get4bytes(long l)	{		// break down to bytes		byte a[] = new byte[4];		a[0] = (byte)((l & 0x00000000ff000000) >> 24);		a[1] = (byte)((l & 0x0000000000ff0000) >> 16);		a[2] = (byte)((l & 0x000000000000ff00) >> 8);		a[3] = (byte)((l & 0x00000000000000ff) >> 0);		// assemble back		// ll != l.		long ll = ((unsigned(a[0]) << 24)&0xff000000) | 				  ((unsigned(a[1]) << 16)&0x00ff0000) | 				  ((unsigned(a[2]) <<8)  &0x0000ff00) | 				  (unsigned(a[3])        &0x000000ff);		System.err.println("original " + l);		System.err.println("new  " + ll);		return a;	}		static byte unsigned(byte b)	{		if (b < 0)		{			b += 128;		}		return b;	}