## NVIDIA Interview Question for Software Engineer / Developers

• 0

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;

}

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;

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

asm: I take that back

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!!!

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.

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;
}``````

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

asm:

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.

### 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.