|
-
Oct 23rd, 2009, 03:10 PM
#1
Thread Starter
New Member
Binary In Java
Hi, I'm new here, and I have one doozy of a code.
Basically It involves binary, which I have little knowledge on how to do in java. It's a very roundabout code, but basically :
a hypothetical multi-touch device encodes information in 64-bit long integers. The values of up to 3 contact points -- (x1,y1), (x2,y2), (x3,y3) -- are recorded as well as the corresponding pressures -- p1, p2, p3.
The number of points reported, n, will be between 0 and 3 and is represented with 2 bits. The touch pad is wider than it is tall, so the x values are reported with 9 bits to give values between 0 and 511. The y values are reported with 7 bits to give values between 0 and 255. Pressure values are reported with 3 bits to give values between 0 and 7.
So this is a 2-parter, the first being a relatively simple CONCEPT. I must
A)Write a method that takes integers, representing x, y and p, and make a 64bit long integer. I’ll have 3 different methods, one for 1 contact point, 1 for 2 contact points, and 1 for 3 contact points. That way I’ll know what automatically what value to use for n.
B) Given a very 64bit integer, I’ll have a code that’ll ask for any of the x1, y1, x2, y2, x3 or y3, and I must supply them with it.
It’s pretty much the concept of the binary that’s throwing me off, really.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|