May. 21st, 2013

izard: (Default)
An engineer at a customer's site asked me an interview question:
// Returns x/y, or 0 if y is 0. Never crashes.
int buggy_div(int x, int y)
{
  if (y == 0)
    return 0;
  return x/y;
}

Why the function above would crash on my computer? There are indeed parameters that make it crash.
Normally I am lagging on this type of problems when you need a quick answer, but it took me 2 minutes to solve this one.
Ideas? Comments are screened for one day.

Profile

izard: (Default)
izard

July 2025

S M T W T F S
  12345
67 8 91011 12
13141516171819
20212223242526
27 28293031  

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 12th, 2025 04:56 am
Powered by Dreamwidth Studios