Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

halkazi Group Title

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?

  • one year ago
  • one year ago

  • This Question is Closed
  1. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    0x is the traditional C way of denoting that the following number is hexadecimal. 0 by itself denotes octal.

    • one year ago
  2. andrew.m.higgs Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Yes, as Rsmith6559 says, everything after the 0x is the actual hex value. In this case, 02B41468.

    • one year ago
  3. halkazi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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?

    • one year ago
  4. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • one year ago
  5. halkazi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • one year ago
  6. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • one year ago
  7. exchaoordo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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?

    • one year ago
  8. exchaoordo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    #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.

    • one year ago
  9. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.