In chap 12, we are asked to
"As an exercise, create and print a Point object, and then use id to print the object's unique identifier. Translate the hexadecimal form into decimal and confirm that they match."
I got an identifier " 0x02B41468".
What does x represent in Hex? If I am able to convert this to Decimal, with what do I have to match it?
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
0x is the traditional C way of denoting that the following number is hexadecimal. 0 by itself denotes octal.
Yes, as Rsmith6559 says, everything after the 0x is the actual hex value. In this case, 02B41468.
Thanks. Ok, so I converted it to Decimal 45,356,136. With what should I match this. Is there a function that will return the Id in Decimal?
Not the answer you are looking for? Search for more explanations.
If you have the code that produced the identifier, there's a formatted print command in there to print it out. If we're talking a C based language, it could well be printf().
Usually in the format string, %x or %X is used for hex and %d is used for decimal.
Your best bet would be to duplicate the line and have one with an x and one with the d.
I guess the exercise is not making sense to me. What do I get by converting an object identifier from Hex to Decimal, and verifying it using a formatting command.
Converting it is a valid exercise, but without the answer you can't be sure that you're right. One way to cheat (it's ethical if it's only to check to see if what you got is right or wrong) is to hack the formatted print statement and let the computer give you the answer.
I have the same question as halkazi: I understand hex and I can convert the id to decimal, but the question says "see if they match." See if WHAT matches?
#halkazi, did you ever get a real answer to this? I came up with: 49595656, with what is one supposed to match it? I don't get the thing about hacking formatted print statements etc.
Most languages use something like C's printf statement's formatting strings. This means that when you print a hexadecimal integer, you format it with "%x". If you want to print it as decimal, the format would be "%d".
If you have the code, find the line that prints out the hex. Make an exact duplicate of that line on the next line, and change the "%x" to "%d" and recompile and run it.