Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Encoding Opcodes ( Exercise question )

  1. #1
    Junior Member
    Join Date
    Aug 2017
    Posts
    23
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question Encoding Opcodes ( Exercise question )

    Am doing the exercises in the first chapter of the book " JAVA PROGRAMMING - From the ground up"

    In the short exercises, 7th exercise, the question is "If there are typically 120 different opcodes and each opcode is represented by a string of bits, how many bits are required to uniquely encode or represent each opcode"

    To be plain here, i dont understand the question at all..

    I assumed the answer is 8 bits since each cell can only hold upto a byte.

    Thank you!
    Last edited by UniverseCloud; August 8th, 2017 at 06:10 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Encoding Opcodes ( Exercise question )

    I think the question is: How many bits does it take to hold a value of 120?
    2 bits can hold 4 different values
    how many bits for 120 different values?
    Its all power of 2.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. accessor and modifier method exercise; exercise 100
    By ghostheadx in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 30th, 2013, 10:18 PM
  2. Exercise 95 (I KNOW, I'm at an earlier exercise)
    By ghostheadx in forum What's Wrong With My Code?
    Replies: 9
    Last Post: December 24th, 2013, 08:42 PM
  3. [SOLVED] Encoding Program
    By geabus1043 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 22nd, 2013, 08:52 PM
  4. Question about an exercise from D.S. Malik's Book "Java Programming"
    By Lahoree in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 15th, 2013, 01:47 AM
  5. Help with character encoding
    By IHeartProgramming in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 20th, 2012, 09:19 PM