Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Edward Bartolo
Bitwise Operators: Pg 63: /* getbits: get n bits from position p */ unigned int getbits(unsigned int x, int p, int n) { return (x >> (p + 1 - n)) & ~(~0 << n); } Why is the book using p + 1 - n?! According to my logic it should use p - 1. Edward __

Re: [DNG] How to stop udev from re-ordering devices

2016-06-24 Thread Simon Hobson
Rainer Weikusat wrote: > That's you're preferred set of workarounds. I suspect that we're all in "violent agreement" that different users (or types of users) have different preferences and priorities. In the general case there is definitely an issue to be solved - just different approaches to

Re: [DNG] How to stop udev from re-ordering devices

2016-06-24 Thread Didier Kryn
Le 23/06/2016 18:33, Rainer Weikusat a écrit : 'Assigning names based on MAC addresses' is problematic as a MAC address is a typically programmable property of a NIC. Yes, *you*, the admin, can change the MAC address. The kernel won't do it, and the hotplugger will do it only if *you* ed

Re: [DNG] How to get rfcomm working again?

2016-06-24 Thread Jaromil
hi, I use the 'rfkill' command for this try 'rfkill list' then 'rfkill un/block' followed by the nr of device found in list hope it helps ciao ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Edward Bartolo
Hi, Never mind, I understood it. Edward On 24/06/2016, Edward Bartolo wrote: > Bitwise Operators: > > Pg 63: > /* getbits: get n bits from position p */ > > unigned int getbits(unsigned int x, int p, int n) > { >return (x >> (p + 1 - n)) & ~(~0 << n); > } > > Why is the book using p + 1 - n

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Hendrik Boom
On Thu, Jun 23, 2016 at 11:34:23PM -0400, Peter Olson wrote: > > On June 23, 2016 at 10:48 AM Edward Bartolo wrote: > > if (count > 0) > > while(putchar(' ') && --count); > > I strongly recommend using the continue statement here: > > while(putchar(' ') && --count) continue; > > The

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Rainer Weikusat
Peter Olson writes: >> On June 23, 2016 at 10:48 AM Edward Bartolo wrote: >> if (count > 0) >> while(putchar(' ') && --count); > > I strongly recommend using the continue statement here: > > while(putchar(' ') && --count) continue; I and I strongly recommend against it. The continue

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Albert van der Horst
Rainer Weikusat schreef op 2016-06-24 18:17: Peter Olson writes: On June 23, 2016 at 10:48 AM Edward Bartolo wrote: if (count > 0) while(putchar(' ') && --count); I strongly recommend using the continue statement here: while(putchar(' ') && --count) continue; I and I strongly

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Peter Olson
On 2016-06-24 12:17, Rainer Weikusat wrote: > Peter Olson writes: >>> On June 23, 2016 at 10:48 AM Edward Bartolo wrote: >>> if (count > 0) >>> while(putchar(' ') && --count); >> >> I strongly recommend using the continue statement here: >> >> while(putchar(' ') && --count) continue;

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Peter Olson
> On June 24, 2016 at 12:45 PM Albert van der Horst > wrote: [...] > Sorry, but that means your brain is not wired correctly to recognize > == as the symmetric operation that it is. > Would you be equally fuzzy about > mask = 0x42 & abc; > versus > mask = abc & 0x42; > ? I'm perfectly

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Rainer Weikusat
Peter Olson writes: > On 2016-06-24 12:17, Rainer Weikusat wrote: >> Peter Olson writes: On June 23, 2016 at 10:48 AM Edward Bartolo wrote: if (count > 0) while(putchar(' ') && --count); >>> >>> I strongly recommend using the continue statement here: >>> >>> while(putc

Re: [DNG] How to stop udev from re-ordering devices

2016-06-24 Thread Rainer Weikusat
Simon Hobson writes: > Rainer Weikusat wrote: >> That's you're preferred set of workarounds. > > I suspect that we're all in "violent agreement" that different users > (or types of users) have different preferences and priorities. In the > general case there is definitely an issue to be solved -

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Steve Litt
On Thu, 23 Jun 2016 23:34:23 -0400 (EDT) Peter Olson wrote: > > On June 23, 2016 at 10:48 AM Edward Bartolo > > wrote: if (count > 0) > > while(putchar(' ') && --count); > > I strongly recommend using the continue statement here: > > while(putchar(' ') && --count) continue; > > Th

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Rainer Weikusat
Albert van der Horst writes: [...] >>> Another habit I have is to avoid a statement like: >>> >>> if (abc == 42) >>> >>> and write it as >>> >>> if (42 == abc) >>> >>> instead. >> >> That's a habit of many people who either believe to be master yoda >> ('Your sister she is') or who belie

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Steve Litt
On Fri, 24 Jun 2016 09:19:40 +0200 Edward Bartolo wrote: > Bitwise Operators: > > Pg 63: > /* getbits: get n bits from position p */ > > unigned int getbits(unsigned int x, int p, int n) > { >return (x >> (p + 1 - n)) & ~(~0 << n); > } Stuff like this is the reason I soon abandoned K&R as

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Joel Roth
Steve Litt wrote: > On Fri, 24 Jun 2016 09:19:40 +0200 > Edward Bartolo wrote: > > > Bitwise Operators: > > > > Pg 63: > > /* getbits: get n bits from position p */ > > > > unigned int getbits(unsigned int x, int p, int n) > > { > >return (x >> (p + 1 - n)) & ~(~0 << n); > > } > > Stuff li

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Irrwahn
On Fri, 24 Jun 2016 19:41:54 +0100, Rainer Weikusat wrote: [...] > If you want > a mathematical example, picture somone always writing > > x / (1/n) > > instead of > > x * n Not to undermine your point, just a minor quibble: The example is flawed in that above terms are not quite equivalent, a

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread KatolaZ
On Fri, Jun 24, 2016 at 09:44:31PM +0200, Irrwahn wrote: > On Fri, 24 Jun 2016 19:41:54 +0100, Rainer Weikusat wrote: > [...] > > If you want > > a mathematical example, picture somone always writing > > > > x / (1/n) > > > > instead of > > > > x * n > > Not to undermine your point, just a mino

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Irrwahn
On Fri, 24 Jun 2016 22:36:33 +0100, Katolaz wrote: > On Fri, Jun 24, 2016 at 09:44:31PM +0200, Irrwahn wrote: >> On Fri, 24 Jun 2016 19:41:54 +0100, Rainer Weikusat wrote: >> [...] >>> If you want >>> a mathematical example, picture somone always writing >>> >>> x / (1/n) >>> >>> instead of >>> >>>

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Irrwahn
On Fri, 24 Jun 2016 14:33:21 -0400, Steve Litt wrote: [...] > I often use continue and break, but every time I do, I make a mental > note that I'm decreasing modularity and thus reducing the scalability > of my code. Of course, I might have also increased my code's > readability by reducing redunda

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread John Morris
On Fri, 2016-06-24 at 15:11 -0400, Steve Litt wrote: > Stuff like this is the reason I soon abandoned K&R as a learning > tool, > and used it only to determine the official behavior of C. > > Bit stuffing, sliding and masking were a tool of the assembly > programmer > back when your RAM could be c

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread aitor_czr
Hi all, On 06/25/2016 12:16 AM, Irrwahn wrote: Well, AIUI it was supposed to be a mathematical example, not a code snippet, but apart from that — yes, indeed. Of course unless x happens to be of floating point type, and n != 0. But then the results for n < -1 or n > 1 would presumably come as

Re: [DNG] Studying C as told. (For help)

2016-06-24 Thread Hendrik Boom
On Sat, Jun 25, 2016 at 01:21:33AM +0200, Irrwahn wrote: > On Fri, 24 Jun 2016 14:33:21 -0400, Steve Litt wrote: > [...] > > I often use continue and break, but every time I do, I make a mental > > note that I'm decreasing modularity and thus reducing the scalability > > of my code. Of course, I mi