NVIDIA Interview Question for Software Engineer / Developers






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

should be correct up to rounding:

unsigned float2fixed(float x) {

unsigned res = (unsigned)floorf(x) << 16;
res |= ((unsigned)floorf(x * 65536.0f) & 0xffff);

}

float fixed2float(unsigned x) {

float res = (float)(x >> 16);
res += (float)(x & 0xffff) / 65536.0f;

}

- asm December 02, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

float a = 2.5
unsigned int n = (unsigned int)a;
float b = a - (float)n;
unsigned int m = (unsigned int)b;

unsigned int result = n << 16 | m;

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

asm: I take that back

- anon March 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2.5 in binary 10.1 = 1.01 * 2^1 => Mantissa 16 bit allocate so its 256+1 = 257
so binary for 257 will be placed 31-16 position
now 31-16 mantissa and 15-0 fractional part 31st bit as a sign bit
0000 0001 0000 0000 0100 0000 0000 0000
0x1004000 is the Answer for the representation!!!

- Anonymous July 28, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int FloatToFixedQ16( const float src )
{
int res = src * (float)( 1 << 16 );

return res;
}

I don't know if it is enough or not. it not, please correct me.

- smartbeast October 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main()
{
	struct abc { int x; char b; float h;};
	float k;
	unsigned int n,j,i,d=0;
	printf("enter float value k=");
	scanf("%f",&k);
	n=k*1000000; // to avoid float value correction
	printf("k=%d\n",n);
	i = n%1000000; 
	n = n/1000000;// to get the decimal value
	if(i)
	{
		while( i%10 == 0)
			i=i/10;	 
	}
	printf("%d %d\n",n,i);
	n = n<<16 | i;
	printf("Hex Value = %X\n",n);
	return 0;
}

- Nireesha October 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

asm:

Your soln doesn't work.

- anon March 16, 2009 | 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