Work in HR or Recruiting?
eBay
3.1 of 5 727 reviews
www.ebay.com San Jose, CA 5000+ Employees

62 interview experiences Back to all eBay Interview Questions & Reviews

Interview Question for Software Engineer at eBay:
Sep 14, 2012

transfer the string hexadecimal number "f3a6.123f" into decimal number.


Add Tags [?]

See more for this eBay Software Engineer Interview

Helpful Question?  
Yes | No
Inappropriate?

Answers & Comments (1)

Nov 12, 2012

by Anonymous:

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.
Helpful Answer?  
Yes | No
Inappropriate?

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.