Thursday, October 9, 2014

Digest for comp.lang.c++@googlegroups.com - 25 updates in 4 topics

comp.lang.c++@googlegroups.com Google Groups
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com.
Robert Hutchings <rm.hutchings@gmail.com>: Oct 09 11:26AM -0500

Given an variable int N, write a function that will reverse all the bits
and return that changed integer variable.
drew@furrfu.invalid (Drew Lawson): Oct 09 04:49PM

In article <m16cvf$j0l$1@dont-email.me>
>Given an variable int N, write a function that will reverse all the bits
>and return that changed integer variable.
 
I had that as a question in a face-to-face interview in 1992,
except that the data was a byte.
 
 
--
Drew Lawson
 
". . . And I never give a reason"
-- God, as channeled by Seven Nations
Robert Hutchings <rm.hutchings@gmail.com>: Oct 09 12:02PM -0500

On 10/9/2014 11:49 AM, Drew Lawson wrote:
>> and return that changed integer variable.
 
> I had that as a question in a face-to-face interview in 1992,
> except that the data was a byte.
 
The online test was hosted by hackerrank.com. For a C++ Dev position, I
thought many of the questions were low-level C questions.
maddoxr@acm.org: Oct 09 10:39AM -0700

On Thursday, October 9, 2014 12:26:47 PM UTC-4, Robert Hutchings wrote:
> Given an variable int N, write a function that will reverse all the bits
 
> and return that changed integer variable.
 
And you, of course, wrote:
 
int ReverseBits(int N)
{
return ~N;
}
 
Which really has nothing to do with C++ being a low-level C thing.
 
Randy.
Robert Hutchings <rm.hutchings@gmail.com>: Oct 09 12:44PM -0500

> }
 
> Which really has nothing to do with C++ being a low-level C thing.
 
> Randy.
 
Exactly! Yes, it helps to have low-level "bits and bytes" knowledge,
but what about OO principles? Is multiple inheritance a good thing? How
is polymorphism handled by compilers? Those are questions I would have
expected...
Robert Hutchings <rm.hutchings@gmail.com>: Oct 09 12:49PM -0500

On 10/9/2014 12:44 PM, Robert Hutchings wrote:
> but what about OO principles? Is multiple inheritance a good thing? How
> is polymorphism handled by compilers? Those are questions I would have
> expected...
Another question was - what is the sizeof a struct with 1 int variable
and 2 virtual functions?
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 09 11:16AM -0700

> }
 
> Which really has nothing to do with C++ being a low-level C thing.
> Randy.
 
I would call that a flip bit function. A reverse bit function could
be interpreted as something like:
 
int ReverseBits(int N)
{
int i, N_new;
 
for (i = 0, N_new = 0; i < sizeof(int) * 8; i++, N >>= 1)
{
N_new <<= 1;
N_new |= (N & 0x1);
}
 
return N_new;
}
 
Best regards,
Rick C. Hodgin
Robert Hutchings <rm.hutchings@gmail.com>: Oct 09 01:18PM -0500

On 10/9/2014 1:16 PM, Rick C. Hodgin wrote:
> }
 
> Best regards,
> Rick C. Hodgin
 
Yes, this is the algorithm that I found most often on the web. Again,
what relevance does this have to a C++ Dev?
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 09 11:29AM -0700

On Thursday, October 9, 2014 2:19:16 PM UTC-4, Robert Hutchings wrote:
> Yes, this is the algorithm that I found most often on the web. Again,
> what relevance does this have to a C++ Dev?
 
If I were guessing... it demonstrates a fundamental understanding of
how things operate below the C/C++ basic types. It lets them know
that you understand "the philosophy" of data, and not just the
workings of a language.
 
Perhaps they're thinking that without a solid foundation of the true
CPU fundamentals, anything you would pursue in C/C++ will be built atop
an unknown, rather than a concrete concept (bytes of data, and not C++
constructs like "int" and "char"), and that without this fundamental
tenant the rest will be unstable and shaky?
 
Perhaps that's their thinking. But, who knows? How does "Why are
manhole covers round?" relate to a developer's ability to write code?
Being creative in understanding an engineering concept doesn't always
translate into the kind of logical and procedural thinking required
to work through some complex algorithm.
 
Nonetheless, you may never know. In my experience, some interviewers
are just plain weird. :-) I once had an interviewer walk out of an
interview mid-stage because I didn't already know how something would
propagate through a macro during compilation. I told him I could compile
an example of the macro and see how it worked, and in that way understand
it, along with any other macros he'd like to show me. He felt that
already having that knowledge was more essential than being able to
figure out how to obtain knowledge I didn't already possess.
 
I'll never forget that interview. :-)
 
Best regards,
Rick C. Hodgin
Robert Hutchings <rm.hutchings@gmail.com>: Oct 09 01:45PM -0500

On 10/9/2014 1:29 PM, Rick C. Hodgin wrote:
 
> I'll never forget that interview. :-)
 
> Best regards,
> Rick C. Hodgin
 
Yes, I see what you mean. Well, whatever. I should hear back today on
my test results...
Robert Wessel <robertwessel2@yahoo.com>: Oct 09 01:57PM -0500

On Thu, 09 Oct 2014 13:18:56 -0500, Robert Hutchings
>> Rick C. Hodgin
 
>Yes, this is the algorithm that I found most often on the web. Again,
>what relevance does this have to a C++ Dev?
 
 
In this case it shows the incompetence of the test writer. Almost
certainly they *wanted* an answer along the lines of the above, but
that clearly does not work (portably) for negative inputs.
 
That being said, I have some sympathy for the HR department in
question. Having spent time on that side of the hiring desk, the raft
of BS you see from candidates makes one long for *any* tool to help
sort the wheat from the chaff.
Martijn Lievaart <m@rtij.nl.invlalid>: Oct 09 08:51PM +0200

On Thu, 09 Oct 2014 12:49:18 -0500, Robert Hutchings wrote:
 
> Another question was - what is the sizeof a struct with 1 int variable
> and 2 virtual functions?
 
That is completely implementation dependent, but one would expect sizeof
(int) + sizeof(vtable*) + padding.
 
M4
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 09 11:57AM -0700

> In this case it shows the incompetence of the test writer. Almost
> certainly they *wanted* an answer along the lines of the above, but
> that clearly does not work (portably) for negative inputs.
 
That may have been part of the test. If so, switch the types to unsigned
int, cast the input to ReverseBits() as (unsigned int), and cast the
return as (int)N_new and now it works on all types. :-)
 
FWIW, I thought bitwise operations always worked properly on signed or
unsigned forms, in that they were implicitly cast to unsigned for the
scope of the bitwise operation.
 
Best regards,
Rick C. Hodgin
Robert Hutchings <rm.hutchings@gmail.com>: Oct 09 02:03PM -0500

On 10/9/2014 1:57 PM, Rick C. Hodgin wrote:
> scope of the bitwise operation.
 
> Best regards,
> Rick C. Hodgin
 
If you cast an int to an unsigned int, do you lose any of the bits? Are
any of the bits changed with this cast?
Jorgen Grahn <grahn+nntp@snipabacken.se>: Oct 09 07:06PM

On Thu, 2014-10-09, Rick C. Hodgin wrote:
> workings of a language.
 
> Perhaps they're thinking that without a solid foundation of the true
> CPU fundamentals [...]
 
Huh? The task was a plain old C++ one, which also happened to be more
or less the same in C.
 
The only weird "under the hood" part was doing it to an int rather
than an unsigned -- I don't know what it means to "reverse the bits"
of a signed integer, and I'm not sure I want to find out. It might
have been a bug in the test.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Jorgen Grahn <grahn+nntp@snipabacken.se>: Oct 09 01:24PM

On Wed, 2014-10-08, David Brown wrote:
...
> from techniques that are more common there and take them back to their
> Windows or *nix programming - the results would often be higher code
> quality.
 
Any examples? I wonder if it's techniques I already use without
thinking about it ...
 
I've done a lot of embedded work, and so far I'm not very impressed.
Although you may be thinking of smaller systems than the ones I've
mostly worked with.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
"Öö Tiib" <ootiib@hot.ee>: Oct 08 04:40PM -0700

On Wednesday, 8 October 2014 23:29:21 UTC+3, Robert Hutchings wrote:
> Does anyone know the legal ramifications of online testing? What if
> they give a test with inaccurate information? Do candidates have any
> legal rights in this area?
 
Work contract is about cooperation with other arseholes. It was taught
you in school. It does not matter what is the question under hand and
it does not matter what is actual truth about it. Best grades you get
for lies that the asking part wants to hear. That is the base of
cooperation. If you want to hear a lie that there are serious legal
ramifications about inaccurate online tests, then search for lawyer
and leave impression that you are wealthy. You'll get the answer since
lawyers have learned to lie for to cooperate.
Geoff <geoff@invalid.invalid>: Oct 08 04:49PM -0700

On Wed, 08 Oct 2014 15:29:03 -0500, Robert Hutchings
>they give a test with inaccurate information? Do candidates have any
>legal rights in this area?
 
>-> Rob
 
No.
 
Just use online test inaccuracies to screen out potential employers.
 
Anyone too stupid to check the tests he's using is too stupid to
tolerate as a superior. It's also quite possible they outsource the
testing and HR has never consulted the relevant department to review
the technical correctness of the tests. Consider it to be just one
more indicator about whether you would be a good fit to their
operation.
"J. Clarke" <jclarkeusenet@cox.net>: Oct 08 08:38PM -0400

In article <c9lshgF8btqU1@mid.individual.net>, ian-news@hotmail.com
says...
> > somewhere in the company decided it was good enough and if they won't
> > accept your pointing out otherwise, what can you do?
 
> Look elsewhere!
 
I wouldn't go so far as to say "most" but many of the online tests are
actually done by "Kenexa Prove It!". Many employment counseling
services can provide you with your own Prove It account that lets you
practice the tests beforehand. Some of them are a bit annoying in that
they assume that you learned a certain way of doing things and if you
can achieve the same result another way may not accept the keystrokes
that let you do it.
Geoff <geoff@invalid.invalid>: Oct 08 06:37PM -0700

On Wed, 8 Oct 2014 16:40:16 -0700 (PDT), 嘱 Tiib <ootiib@hot.ee>
wrote:
 
>ramifications about inaccurate online tests, then search for lawyer
>and leave impression that you are wealthy. You'll get the answer since
>lawyers have learned to lie for to cooperate.
 
In other words, when the emperor has no clothes it's best to nod and
admire the clothes.
woodbrian77@gmail.com: Oct 08 10:20PM -0700

On Wednesday, October 8, 2014 8:36:55 PM UTC-5, Geoff wrote:
> >lawyers have learned to lie for to cooperate.
 
> In other words, when the emperor has no clothes it's best to nod and
> admire the clothes.
 
I think it's best to be a whistle blower.
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
Sam <sam@email-scan.com>: Oct 09 05:48AM -0500

Robert Hutchings writes:
 
> Does anyone know the legal ramifications of online testing? What if they
> give a test with inaccurate information? Do candidates have any legal
> rights in this area?
 
In this situation, you have every legal right to reconsider your intentions
of getting hired by the company in question.
JiiPee <no@notvalid.com>: Oct 09 02:22PM +0100

On 08/10/2014 23:17, Christopher Pisz wrote:
> more and reject me. I viewed it as a win, because I don't want to work
> for a supervisor that A) Does not respect and consider my opinion
> given my experience B) Takes personal offense when proven wrong
 
Yes exatcly. People should humble themselves up and take correction when
its given with a proof. That should have been positive not negative
point that you found such an error. This is how humanity is...
 
 
> I really expected bonus points if anything!
 
ye
 
JiiPee <no@notvalid.com>: Oct 09 02:24PM +0100

On 09/10/2014 00:40, Öö Tiib wrote:
> you in school. It does not matter what is the question under hand and
> it does not matter what is actual truth about it. Best grades you get
> for lies that the asking part wants to hear.
 
but this is simply wrong way to do things, just my 2 cents....
 
Jorgen Grahn <grahn+nntp@snipabacken.se>: Oct 09 07:52AM

On Tue, 2014-10-07, 嘱 Tiib wrote:
> On Tuesday, 7 October 2014 21:58:34 UTC+3, woodb...@gmail.com wrote:
...
 
> However 'cmw_account_info'? It is such
> average name, only half of it is meaningless bloat and nothing
> is misleading. Tolerable.
 
I sometimes use the word "info" myself in variable and type names, but
it's a small warning flag. E.g. is there a difference between a CMW
Account object and the object carrying /info/ about a CMW Account?
 
More direct wording is better; it helps you think.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: