Olin, You are completely right about the misplaced colons. See you understand C better than you let on :) And, you are also right about the mailroom reassignment. Bob Ammerman RAm Systems ----- Original Message ----- From: "Olin Lathrop" To: "Microcontroller discussion list - Public." Sent: Thursday, February 17, 2005 7:56 AM Subject: Re: [EE] Languages, was Bug in Microchip mcc18 std library? > Bob Ammerman wrote: >> switch (n) >> default:: >> if (isprime(n)) >> case 2: case 3: case 5: case 7: p = 1; >> else >> case 4: case 6: case 8 case 9: : p=0; >> >> If it is, what on earth does it do? (and why!) > > I don't know enough about C to know whether its legal, and am too lazy to > run it thru a compiler to see. What is the double colon after DEFAULT? > Shouldn't there be one colon after "8" and only one after "9"? > > In any case, it looks like this sets P to 1 if N is prime, and 0 if it's > not. Values from 2-9 are handled outright, and values outside that range > are evaluated by the ISPRIME function. At least that's what the intent > appears to be. > > While this may be cutesy intellectual exercise, anyone who puts this in > production code should be demoted to assistant mailroom clerk straight > away. > > > ***************************************************************** > Embed Inc, embedded system specialists in Littleton Massachusetts > (978) 742-9014, http://www.embedinc.com > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist