eBay Inc.

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

eBay Inc. Software Engineer Interview Question (student candidate)

I interviewed in Pittsburgh, PA and was asked:
"transfer the string hexadecimal number "f3a6.123f" into decimal number."
Add Tags [?]
Answer

Part of a Software Engineer Interview Review - one of 326 eBay Inc. Interview Reviews

Answers & Comments

0
of 0
votes
1. Need a hex to decimal lookup table (e.g. java hashmap).
2. Convert string to char[].
3. Find the location of decimal point 'K'.
double result;
char[] data; // input
for(i = K-1; i >= 0,; i--){
  result += lookup.get(data[i])*Math.pow(16,K-1-i);
}
for(i=K+1; i<data.length; i++){
  result += lookup.get(data[i])*Math.pow(16,-(i-K));
}
return result;

I haven't tested this, so test if before you use it.
- Anonymous on Nov 12, 2012

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

Tags are like keywords that help categorize interview questions that have something in common.