4 ms·
> "To achieve this, the guidance system converts the velocity readings, from 64 bit floating point to 16 bit signed integer". Oh, excellent possible interview
by photochemsyn 4y ago
> "To achieve this, the guidance system converts the velocity readings, from 64 bit floating point to 16 bit signed integer".
Oh, excellent possible interview question? "Write some code that reliably converts the full range of possible 64 bit floating point values to a 16 bit signed integer. What are the issues you'll have to deal with and what edge cases might arise?"
- l33t233372 4y agoIf I had this question and I couldn’t look up IEEE 754 I would be cooked. Maybe I have no business writing floating point code.
- yellow_postit 4y agoOr it’s a bad interview question as posed because in practice you could look up the spec and a better question would be to probe how the candidate would approach the problem and what clarify questions they would ask.
- touisteur 4y agoAnd most likely any serious Ada codebase worked by people worrying about such a question, has this in a generics or done (correctly) 7000 times... 'I'd just instantiate the Quantizer or Quantization_Manager generics, y'all have one, right?'
- gowld 4y agoIt's a bad question because it's completely impossible, so the interviewee has to guess if the interviewer knew that and looking for pushback, or didn't know that and you have to figure out what they actually meant and what they incorrectly think the answer is supposed to be.
- vba616 4y agoI'd be like: Step 1: Enumerate all possible inputs. <--- this is the important part Step 2: Map each input to something in the output domain. Step 3: Are you using Ada??? C++ is *right out*. ...it looks like the proper name for what is needed is a "non-injective surjective total function".
- gowld 4y agoThey are asking for an injective function, which is impossible.
- joshAg 4y ago".... i can't. No one can. It's a mathematical impossibility as a general solution for at least 2 separate reasons. The first issue is that we're taking 64 bits of data and trying to squeeze them into 16 bits. Now, sure it's not that bad, because we have the sign bit and NANs and infinities, but even if you toss away the exponent entirely, that's still 53 bits of mantissa to squeeze into 16 bits of int. The second issue is all the values not directly expressible as an integer, either because they're infinity, NAN, too big, too small, or fractional. The only way we can overcome these issues is to decide what exactly we mean by "converts", because while we might not _like_ it, casting to an int64 and then masking off our 16 most favorite bits of the 64 available is a stable conversion. That might be silly, but it brings up a valid question. What is our conversion algorithm? Maybe by "convert" we meant map from the smallest float to the smallest int and then the next smallest float to the next smallest int, and then either wrapping around or just pegging the rest to the int16.max. Or maybe we meant from the biggest float to the biggest int and so on doing the inverse of the previous. Those are two very different results. And we haven't even considered whether to throw on NAN or infinity or what to do with -0 for both those cases. Or maybe we meant translate from the float value to the nearest representable integer? We'd have a lot of stuff mapping to int16.max and int16.min, and we'd still have to decide how to handle infinity, NAN, and -0, but still possible. Basically, until we know the rough conversion function, we can't even know if NAN, infinity and -0 are special cases and we can't even know if clipping will be an edge case or not. There's lots of conversions where we can happily wrap around on ourself and there are no edge cases, and there's lots of conversions where we have edge cases, but we can clip or wrap, and there's lots of conversions where we have edge cases and clipping/wrapping."
- vaidhy 4y agoYou are hired!!!
- zaroth 4y agoOh come now that’s just silly! I’ve interviewed 8 web devs over the last two weeks, each with years of experience, each asking $115k+, and more than one couldn’t figure out how to take an array of objects each with a ‘category’ property and output an array with the unique values of ‘category’. (this is one line of code) Only one could successfully wire up a <select> populated with the list of unique categories and then filter the original list based on the selected category. By the way, these interviews were done over Zoom with screen sharing with the candidate able to use their own dev environment and browser of their choice. The interviews were allotted one hour and all candidates took longer than the scheduled time. It’s been beyond depressing. I’m ready to just start asking for FizzBuzz again.