Intel Corporation

  www.intel.com
Work in HR? Unlock Free Profile

Intel Corporation Post Silicon Validation Engineer Interview Question

I interviewed in Folsom, CA and was asked:
"Convert a decimal number into binary form."
Add Tags [?]
Answer

Part of a Post Silicon Validation Engineer Interview Review - one of 1,376 Intel Corporation Interview Reviews

Answers & Comments

0
of 0
votes

If you are not very familiar with the powers of 2, you can write them down, from left to right, before starting the process. eg. 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1

Find the largest power of 2 that is less than the decimal number, then:

1 - write a '1' for that power-of-2's column
2 - subtract that power-of-2 from the number and keep the remainder
3 - check next lower power-of-2 to see if it is less than the remainder
4 - if no write a '0' for that power-of-2's place and goto step 3
5 - if yes, goto step 1

Example:
Starting with the decimal number 209, the largest power-of-2 that is less than 209 is 128. We write a '1' and subtract 128 from 209 leaving 81. The next smaller power-of-2 is 64. 64 is less than 81 so we write a '1', subtract 64 from 81 leaving a remainder of 17. We then check 32 and write a '0', check 16 and write a '1', leaving a remainder of 1. Next is 8, then 4, then 2, taking a '0' for each leaving a '1' for 1. Putting all this together yields a solution of '11010001' binary, which is 0xD1 (hex) and 209 decimal.
I hope this helps.

- JimmyT on Sep 03, 2013

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords, helping to categorise interview questions that have something in common.