Hey Salman, <code> // we won't get overflow with these values // this will give a nice gaussian value; int step = 1; for (int j = 0; j < 50; j++) { if (rnd.nextBoolean()) { step++; } } </code> I wanted to make a gaussian random function, so I looped 50 times and took a random bool. If the random was true I added 1. if it wasn't I did not add anything. Basically add 50 coin tosses. :)
<code> public static final byte[] intToByteArray(int value) { return new byte[] { (byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) value }; } </code> The trace is big endian. I think it was in the spec somewhere. I goofed with the comments, good catch. The integers need to be in big endian then. Java stores them in a big endian format. So, if you have 1337, in hex in big endian it is 0x0539 in little endian it is 0x3905. you have the bytes 0x05 and 0x39 that are stored either msB first (big endian) or lsB first (little endian) fun read: http://en.wikipedia.org/wiki/Endianness so if my int is 0x01234567, I want it stored as 0x01234567. I break it up into 4 bytes. the first byte are the first 8 bytes. Since an int is 32, I down shift by 24 to make 8. I cast it as a byte to discard all the other bits. the second byte should be the 24-16 byte, so I downshift by 16. The third is 16-8 so I down shift by 8 the bytes in a big endian array would be : 0x01, 0x23, 0x45, 0x67. Hope that clears things up. Thanks for the catch. BR, Matthew On 13-07-08 08:44 PM, sa_ho...@encs.concordia.ca wrote: > Hello > I'm new to TMF framework, I started with reading the tutorial and I > downloaded the code for NexusLite trace type. > in the file, MakeMeNexus there is a for loop which executes 50 times. > what does this for do? > second, the what is the scemantics behind the shifting operations in > the method intToByteArray() ? > Regards > > _______________________________________________ > linuxtools-dev mailing list > linuxtools-dev@eclipse.org > https://dev.eclipse.org/mailman/listinfo/linuxtools-dev _______________________________________________ linuxtools-dev mailing list linuxtools-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/linuxtools-dev