menu
bartleby
search
close search
Hit Return to see all results

I am trying to convert a number to hexadecimal. How do I do this without using modulus, division, and multiplication. Also, I can't import anything and I can't use any functions like Integer.toHexadecimal().

Question

I am trying to convert a number to hexadecimal. How do I do this without using modulus, division, and multiplication. Also, I can't import anything and I can't use any functions like Integer.toHexadecimal().

check_circleAnswer
Step 1

To convert a decimal number into hexadecimal form with out using any of modulus, division or multiplication operator you need to use shift operators.

Step 2

The following code can be used to convert the number in decimal form into hexadecimal form using right shift operator:

fullscreen
Step 3

In the above program the for loop in line 39 will execute 7 times for the int type storage of 4 bytes. During the first iteration i will take the value of 7 i.e. (2×4) –1 =7. Then in the line 40, the input number “num” will be right sh...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: For this program you need to use Eclipse

A: Program plan:Declare the integer variables “coin” and “guess” and string variable “num”.Generate the...

question_answer

Q: Write a program in Eclipse that prompts the user to enter a string and displays the number of vowels...

A: Solution:Given data, The java code gets the input string from user and display the number of vowels ...

question_answer

Q: Design a Turing machine that computes the function f (x) = x − 2 if x > 2   = 0 i...

A: Click to see the answer

question_answer

Q: Consider the languages below. For each, make a conjecture whether or not it is regular. Then prove y...

A: The given language L = {anbl : n/l is an integer} is not regular language because a DFA cannot be co...

question_answer

Q: Write a class in java with the name AgeMessages , which does the following:a. Ask the user to enter...

A: The algorithm for the program would be as below:Declare one float variable for accepting user inputP...

question_answer

Q: Write a program that contains 2 methods, main and printLine (10 points)1) The printLine method will ...

A: Declare required variables ‘first’, ‘second’ and ‘times’ which is used to store first character, sec...

question_answer

Q: The nor of two languages is nor (L1, L2) = {w : w ∉ L1 and w ∉ L2}. Show that the family of regular ...

A: Click to see the answer

question_answer

Q: write a program in c++. You work for a box company, and have been asked to write a program to compar...

A: Click to see the answer

question_answer

Q: Give the derivation tree for ((a+b)∗c+d, using the grammar in Example 5.12. EXAMPLE 5.12 To rewrite ...

A: To solve your problem first of all we define  What is Context Free grammer  and  Derivation tree? Co...

Sorry about that. What wasn’t helpful?