VMWare Inc Interview Question for Software Engineers


Country: United States
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
1
of 1 vote

bool X86IsCanonicalAddress(void *a) {
	void *b = 0xffff000000000000;
	if ((a & b) == b)
		return true;

	if ((a ^ b) & b == b)
		return true;

	return false;
}

- Mukesh July 07, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

I think all you need to do for this one is isolate the high 16 bits to see if they are all 0 or 1.

bool X86IsCanonicalAddress(int a) {
	// Return true if lowest 48 bits are equal and highest 16 bits are all 1 or all 0
	// Assumes compiler treats int as unsigned 64bit and does arithmetic shifting

	// Isolate the highest 16 bits. 
	// If all 1, result will be -1 due to arithmetic type shifting. 
	// If all 0, result is 0
	int high16 = a >> 48;

	if(high16 == -1 || high16 == 0) {
		return true;
	}

	return false;
}

- vthyng August 06, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you please explain the code above?

- Ramraj July 20, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Simple:

bool isCanonical(unsigned long long add) {

	unsigned long long int mask = 0xFFFF000000000000;

	return (!(add & mask));

}

- Moose August 22, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

BigInteger bigInt = new BigInteger(inputString, 2);
        return  new BigInteger(binStr, 2);.shiftRight(48).equals(new BigInteger("1111111111111111", 2)) || bigInt.shiftRight(48).equals(new BigInteger("0000000000000000", 2));

- Rohan September 21, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think the question might be missing a detail. According to the wiki, canonical address definition is like this:
"... the AMD specification requires that bits 48 through 63 of any virtual address must be copies of bit 47"

- rmn October 15, 2016 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More