Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #55535 > unrolled thread
| Started by | EQuestionAnswers Inc <equestionanswers@gmail.com> |
|---|---|
| First post | 2014-12-27 22:41 -0800 |
| Last post | 2015-01-03 19:46 +0000 |
| Articles | 17 — 10 participants |
Back to article view | Back to comp.lang.c
www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study EQuestionAnswers Inc <equestionanswers@gmail.com> - 2014-12-27 22:41 -0800
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Barry Schwarz <schwarzb@dqel.com> - 2014-12-28 10:02 -0800
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-12-28 19:55 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study bert <bert.hutchings@btinternet.com> - 2014-12-28 12:41 -0800
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-12-28 20:47 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study BartC <bc@freeuk.com> - 2014-12-28 21:48 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-12-29 00:57 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Phil Carmody <pc+usenet@asdf.org> - 2015-01-03 15:08 +0200
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study BartC <bc@freeuk.com> - 2015-01-03 13:31 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-01-03 15:13 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study BartC <bc@freeuk.com> - 2015-01-03 21:23 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Dr Nick <nospam-4@temporary-address.org.uk> - 2014-12-29 09:45 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Ike Naar <ike@iceland.freeshell.org> - 2014-12-29 09:57 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study bert <bert.hutchings@btinternet.com> - 2014-12-29 04:07 -0800
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Phil Carmody <pc+usenet@asdf.org> - 2015-01-03 15:43 +0200
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-01-03 13:57 +0000
Re: www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study Greg Martin <greg.at.softsprocket@dot.com> - 2015-01-03 19:46 +0000
| From | EQuestionAnswers Inc <equestionanswers@gmail.com> |
|---|---|
| Date | 2014-12-27 22:41 -0800 |
| Subject | www.equestionanswers.com - C,C++, VC++,MFC,COM,DCOM, DLL question and answers for interviews and self-study |
| Message-ID | <47f4e1c7-9a9d-48b2-9ba8-4f8c0b4be07f@googlegroups.com> |
Hi, This is our website http://www.equestionanswers.com loaded with C,C++, VC++,MFC,COM,DCOM, DLL question and answers, targeted for interviews and self-study. Hope you like this forum. Thanks and regards, webmaster
[toc] | [next] | [standalone]
| From | Barry Schwarz <schwarzb@dqel.com> |
|---|---|
| Date | 2014-12-28 10:02 -0800 |
| Message-ID | <n0h0aadudc4ikp2cdp4umi3f7bea53315j@4ax.com> |
| In reply to | #55535 |
On Sat, 27 Dec 2014 22:41:18 -0800 (PST), EQuestionAnswers Inc <equestionanswers@gmail.com> wrote: >Hi, > >This is our website http://www.equestionanswers.com loaded with C,C++, VC++,MFC,COM,DCOM, DLL question and answers, targeted for interviews and self-study. Hope you like this forum. Any site that says "Pointer is nothing but an unsigned long number" is probably worth avoiding. -- Remove del for email
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2014-12-28 19:55 +0000 |
| Message-ID | <87d273czw7.fsf@bsb.me.uk> |
| In reply to | #55553 |
Barry Schwarz <schwarzb@dqel.com> writes: > On Sat, 27 Dec 2014 22:41:18 -0800 (PST), EQuestionAnswers Inc > <equestionanswers@gmail.com> wrote: > >>Hi, >> >>This is our website http://www.equestionanswers.com loaded with >> C,C++, VC++,MFC,COM,DCOM, DLL question and answers, targeted for >> interviews and self-study. Hope you like this forum. > > Any site that says "Pointer is nothing but an unsigned long number" is > probably worth avoiding. If we're picking favourites... Take a look at the highest common factor program. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | bert <bert.hutchings@btinternet.com> |
|---|---|
| Date | 2014-12-28 12:41 -0800 |
| Message-ID | <d754b314-f1e5-4b34-913c-5e4626bca1b9@googlegroups.com> |
| In reply to | #55556 |
On Sunday, 28 December 2014 19:56:02 UTC, Ben Bacarisse wrote: > ... Take a look at the highest common factor program. Your age is showing, Ben, and so would mine. Currently, the preferred terminology is greatest common divisor. --
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2014-12-28 20:47 +0000 |
| Message-ID | <87ppb3biyh.fsf@bsb.me.uk> |
| In reply to | #55557 |
bert <bert.hutchings@btinternet.com> writes: > On Sunday, 28 December 2014 19:56:02 UTC, Ben Bacarisse wrote: >> ... Take a look at the highest common factor program. > > Your age is showing, Ben, and so would mine. Currently, > the preferred terminology is greatest common divisor. It's also my preferred term (does that make me young again?!), but I thought I'd stick with the term used by the site in question so people could find it (though, really, don't bother). -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | BartC <bc@freeuk.com> |
|---|---|
| Date | 2014-12-28 21:48 +0000 |
| Message-ID | <gV_nw.239857$Cy6.150958@fx23.am4> |
| In reply to | #55558 |
On 28/12/2014 20:47, Ben Bacarisse wrote:
> bert <bert.hutchings@btinternet.com> writes:
>
>> On Sunday, 28 December 2014 19:56:02 UTC, Ben Bacarisse wrote:
>>> ... Take a look at the highest common factor program.
>>
>> Your age is showing, Ben, and so would mine. Currently,
>> the preferred terminology is greatest common divisor.
>
> It's also my preferred term (does that make me young again?!), but I
> thought I'd stick with the term used by the site in question so people
> could find it (though, really, don't bother).
Too late. But I couldn't find it using either 'highest' or 'greatest' on
the page of C questions. (I had to use the search box.)
What was the problem with the code anyway, the algorithm? It worked,
sort of (it's slow for big numbers, and returns garbage when there is no
gcd >= 2 or both operands are negative).
It does however use scanf("%d %d",&a,&b) which I had more of an issue
with: it seems the separator has to be white-space only, you can't use a
comma. Another mark against scanf.
--
Bartc
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2014-12-29 00:57 +0000 |
| Message-ID | <878uhrb7c8.fsf@bsb.me.uk> |
| In reply to | #55559 |
BartC <bc@freeuk.com> writes:
> On 28/12/2014 20:47, Ben Bacarisse wrote:
>> bert <bert.hutchings@btinternet.com> writes:
>>
>>> On Sunday, 28 December 2014 19:56:02 UTC, Ben Bacarisse wrote:
>>>> ... Take a look at the highest common factor program.
>>>
>>> Your age is showing, Ben, and so would mine. Currently,
>>> the preferred terminology is greatest common divisor.
>>
>> It's also my preferred term (does that make me young again?!), but I
>> thought I'd stick with the term used by the site in question so people
>> could find it (though, really, don't bother).
>
> Too late. But I couldn't find it using either 'highest' or 'greatest'
> on the page of C questions. (I had to use the search box.)
Odd. Maybe we are looking at different pages.
> What was the problem with the code anyway, the algorithm? It worked,
> sort of (it's slow for big numbers, and returns garbage when there is
> no gcd >= 2 or both operands are negative).
I'd think that would be enough for anyone! The algorithm is
preposterous, and it fails more often than it succeeds, but I see you
got right to the heart of the problem...
> It does however use scanf("%d %d",&a,&b) which I had more of an issue
> with: it seems the separator has to be white-space only, you can't use
> a comma. Another mark against scanf.
Shocking! What would you'd do instead?
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Phil Carmody <pc+usenet@asdf.org> |
|---|---|
| Date | 2015-01-03 15:08 +0200 |
| Message-ID | <8761co2erw.fsf@bazspaz.fatphil.org> |
| In reply to | #55559 |
BartC <bc@freeuk.com> writes:
> On 28/12/2014 20:47, Ben Bacarisse wrote:
> > bert <bert.hutchings@btinternet.com> writes:
> >
> >> On Sunday, 28 December 2014 19:56:02 UTC, Ben Bacarisse wrote:
> >>> ... Take a look at the highest common factor program.
> >>
> >> Your age is showing, Ben, and so would mine. Currently,
> >> the preferred terminology is greatest common divisor.
> >
> > It's also my preferred term (does that make me young again?!), but I
> > thought I'd stick with the term used by the site in question so people
> > could find it (though, really, don't bother).
>
> Too late. But I couldn't find it using either 'highest' or 'greatest'
> on the page of C questions. (I had to use the search box.)
If you were aware that it might be called either HCF or GCD,
then why didn't you search for "common" instead - it's the
second instance on the page.
Then again, it's the first and only instance on the page of
"highest", so perhaps you should investigate getting a browser
with less brokenness.
> What was the problem with the code anyway, the algorithm? It worked,
> sort of (it's slow for big numbers, and returns garbage when there is
> no gcd >= 2 or both operands are negative).
Isn't being 3 times longer than code that actually works, and scales
well for large numbers (being linear rather than exponential in the
size of the input) reason enough to barf at the sight of it? I was
half way between barf and laugh, certainly. (Thanks, Ben, for the
laugh half!)
> It does however use scanf("%d %d",&a,&b) which I had more of an issue
> with: it seems the separator has to be white-space only, you can't use
> a comma. Another mark against scanf.
Code showing you how to take the GCD of two numbers has no
reason to show you how to input two numbers anyway, that's
an answer to a different question.
Phil
--
The best part of re-inventing the wheel is that you get to pick how
many sides the new one has. -- egcagrac0 on SoylentNews
[toc] | [prev] | [next] | [standalone]
| From | BartC <bc@freeuk.com> |
|---|---|
| Date | 2015-01-03 13:31 +0000 |
| Message-ID | <qbSpw.454986$tr6.398020@fx15.am4> |
| In reply to | #55720 |
On 03/01/2015 13:08, Phil Carmody wrote: > BartC <bc@freeuk.com> writes: >> On 28/12/2014 20:47, Ben Bacarisse wrote: >>> bert <bert.hutchings@btinternet.com> writes: >>> >>>> On Sunday, 28 December 2014 19:56:02 UTC, Ben Bacarisse wrote: >>>>> ... Take a look at the highest common factor program. >>>> >>>> Your age is showing, Ben, and so would mine. Currently, >>>> the preferred terminology is greatest common divisor. >>> >>> It's also my preferred term (does that make me young again?!), but I >>> thought I'd stick with the term used by the site in question so people >>> could find it (though, really, don't bother). >> >> Too late. But I couldn't find it using either 'highest' or 'greatest' >> on the page of C questions. (I had to use the search box.) > > If you were aware that it might be called either HCF or GCD, > then why didn't you search for "common" instead - it's the > second instance on the page. > > Then again, it's the first and only instance on the page of > "highest", so perhaps you should investigate getting a browser > with less brokenness. On which page exactly? I was looking at http://www.equestionanswers.com/c-questions.php, Questions and Answers on C Programming. Question 2 is about the history of C. That's the only relevant link I could find from the page the OP posted, in from the section called "C/C++ Questions and Answers". I don't know what other people are looking at. Perhaps a direct URL to that question page (or some information as to exactly what they had to click in the OP's link) would help. -- Bartc
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-01-03 15:13 +0000 |
| Message-ID | <87oaqf7v7u.fsf@bsb.me.uk> |
| In reply to | #55723 |
BartC <bc@freeuk.com> writes: > On 03/01/2015 13:08, Phil Carmody wrote: >> BartC <bc@freeuk.com> writes: >>> On 28/12/2014 20:47, Ben Bacarisse wrote: >>>> bert <bert.hutchings@btinternet.com> writes: >>>> >>>>> On Sunday, 28 December 2014 19:56:02 UTC, Ben Bacarisse wrote: >>>>>> ... Take a look at the highest common factor program. >>>>> >>>>> Your age is showing, Ben, and so would mine. Currently, >>>>> the preferred terminology is greatest common divisor. >>>> >>>> It's also my preferred term (does that make me young again?!), but I >>>> thought I'd stick with the term used by the site in question so people >>>> could find it (though, really, don't bother). >>> >>> Too late. But I couldn't find it using either 'highest' or 'greatest' >>> on the page of C questions. (I had to use the search box.) >> >> If you were aware that it might be called either HCF or GCD, >> then why didn't you search for "common" instead - it's the >> second instance on the page. >> >> Then again, it's the first and only instance on the page of >> "highest", so perhaps you should investigate getting a browser >> with less brokenness. > > On which page exactly? > > I was looking at http://www.equestionanswers.com/c-questions.php, > Questions and Answers on C Programming. Question 2 is about the > history of C. And does your browser not let you search "in page"? I just search for "highest" and there it is. The word "common" matches three times, the second being the one talked about here (question 132, by the way). <snip> > [...] Perhaps a direct URL to > that question page (or some information as to exactly what they had to > click in the OP's link) would help. http://www.equestionanswers.com/c/c-hcf.php -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | BartC <bc@freeuk.com> |
|---|---|
| Date | 2015-01-03 21:23 +0000 |
| Message-ID | <S5Zpw.288226$P42.35717@fx24.am4> |
| In reply to | #55738 |
On 03/01/2015 15:13, Ben Bacarisse wrote: > BartC <bc@freeuk.com> writes: >> I was looking at http://www.equestionanswers.com/c-questions.php, >> Questions and Answers on C Programming. Question 2 is about the >> history of C. > > And does your browser not let you search "in page"? I just search for > "highest" and there it is. The word "common" matches three times, the > second being the one talked about here (question 132, by the way). It does. But it appears that my browser search was set up to match case exactly... I must used clicked that at some point in the past, but applications these days seem to have long memories. -- Bartc
[toc] | [prev] | [next] | [standalone]
| From | Dr Nick <nospam-4@temporary-address.org.uk> |
|---|---|
| Date | 2014-12-29 09:45 +0000 |
| Message-ID | <87fvbyiybs.fsf@temporary-address.org.uk> |
| In reply to | #55556 |
Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > Barry Schwarz <schwarzb@dqel.com> writes: > >> On Sat, 27 Dec 2014 22:41:18 -0800 (PST), EQuestionAnswers Inc >> <equestionanswers@gmail.com> wrote: >> >>>Hi, >>> >>>This is our website http://www.equestionanswers.com loaded with >>> C,C++, VC++,MFC,COM,DCOM, DLL question and answers, targeted for >>> interviews and self-study. Hope you like this forum. >> >> Any site that says "Pointer is nothing but an unsigned long number" is >> probably worth avoiding. > > If we're picking favourites... Take a look at the highest common factor > program. Putting aside the (unused) non-standard header, don't you think you're being a bit harsh here? It's not as though anyone has recently discovered a better algorithm or anything.
[toc] | [prev] | [next] | [standalone]
| From | Ike Naar <ike@iceland.freeshell.org> |
|---|---|
| Date | 2014-12-29 09:57 +0000 |
| Message-ID | <slrn3vfsma29co.k9r.ike@iceland.freeshell.org> |
| In reply to | #55561 |
On 2014-12-29, Dr Nick <nospam-4@temporary-address.org.uk> wrote: > Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > >> Barry Schwarz <schwarzb@dqel.com> writes: >> >>> On Sat, 27 Dec 2014 22:41:18 -0800 (PST), EQuestionAnswers Inc >>> <equestionanswers@gmail.com> wrote: >>> >>>>Hi, >>>> >>>>This is our website http://www.equestionanswers.com loaded with >>>> C,C++, VC++,MFC,COM,DCOM, DLL question and answers, targeted for >>>> interviews and self-study. Hope you like this forum. >>> >>> Any site that says "Pointer is nothing but an unsigned long number" is >>> probably worth avoiding. >> >> If we're picking favourites... Take a look at the highest common factor >> program. > > Putting aside the (unused) non-standard header, don't you think you're > being a bit harsh here? It's not as though anyone has recently > discovered a better algorithm or anything. Euclid discovered a better algorithm (but not recently).
[toc] | [prev] | [next] | [standalone]
| From | bert <bert.hutchings@btinternet.com> |
|---|---|
| Date | 2014-12-29 04:07 -0800 |
| Message-ID | <cfff8f54-ef66-46f3-b6f6-c7a251218337@googlegroups.com> |
| In reply to | #55562 |
On Monday, 29 December 2014 09:57:56 UTC, Ike Naar wrote: > On 2014-12-29, Dr Nick <nospam-4@temporary-address.org.uk> wrote: > > It's not as though anyone has recently > > discovered a better algorithm or anything. > > Euclid discovered a better algorithm (but not recently). Stein's algorithm avoids divisions, except by 2. One of the web pages about it dates it from 1967, but admits that it might be quite a lot older. It does have similarities to the "Russian peasant" method of multiplication. --
[toc] | [prev] | [next] | [standalone]
| From | Phil Carmody <pc+usenet@asdf.org> |
|---|---|
| Date | 2015-01-03 15:43 +0200 |
| Message-ID | <871tnc2d46.fsf@bazspaz.fatphil.org> |
| In reply to | #55564 |
bert <bert.hutchings@btinternet.com> writes: > On Monday, 29 December 2014 09:57:56 UTC, Ike Naar wrote: > > On 2014-12-29, Dr Nick <nospam-4@temporary-address.org.uk> wrote: > > > It's not as though anyone has recently > > > discovered a better algorithm or anything. > > > > Euclid discovered a better algorithm (but not recently). > > Stein's algorithm avoids divisions, except by 2. Euclid's algorithm didn't have any divisions to avoid. > One of the web > pages about it dates it from 1967, but admits that it might be > quite a lot older. It does have similarities to the "Russian > peasant" method of multiplication. Indeed, Stein was published in 67, but I think he discovered it in 1961. I don't really see the similarity between with the Russian peasant method (although perhaps I've only seen an abstraction of that method which has removed the similarity). Whilst Stein's is genuinely a different algorithm from Euclid's, rather than merely an optimisation (unlike the division-based optimisation of Euclid, which essentially dates back to Lehmer in the 30s), it's still not a huge leap from the original. Sorensen tweaked Stein in the 90s. In simplest possible terms, Sorensen : Stein :: Lehmer : Euclid. Knuth and Schoenhage approached the problem in different fields (and by which, I don't mean "fields", which have no GCD) which don't necessarily easily apply to the integer problem way back in the early 70s. The only method for integers that is significantly different from the original, IMHO, is Stehle and Zimmerman's, but in essense this is just wringing the maximum from Sorensen's improvements of Stein's (taking it to 'divide and conquer' levels, rather than just chipping away bits). Phil, who realised that in his previous post, his "linear" comment was assuming a computational model where add/shift/etc. take constant time on any size input. (Such as a modern PC with fixed size arithmetic types - which was the model we were in, so it wasn't such a guff. In Big-Oh-land, such ops are linear, so Euclid is quadratic.) -- The best part of re-inventing the wheel is that you get to pick how many sides the new one has. -- egcagrac0 on SoylentNews
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2015-01-03 13:57 +0000 |
| Message-ID | <slrnmafta5.4et.grahn+nntp@frailea.sa.invalid> |
| In reply to | #55553 |
On Sun, 2014-12-28, Barry Schwarz wrote: > On Sat, 27 Dec 2014 22:41:18 -0800 (PST), EQuestionAnswers Inc > <equestionanswers@gmail.com> wrote: > >>Hi, >> >>This is our website http://www.equestionanswers.com loaded with C,C++, VC++,MFC,COM,DCOM, >> DLL question and answers, targeted for interviews and self-study. Hope you like this forum. > > Any site that says "Pointer is nothing but an unsigned long number" is > probably worth avoiding. Why is it that idiots try to teach C programming? Don't they have anything better to do, being silently incompetent or something? I'm no great programmer or tutor, but even I could do a decent job of explaining pointers. An expose of historical pointer implementations would replace that sentence, and explain a hell of a lot more ... /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | Greg Martin <greg.at.softsprocket@dot.com> |
|---|---|
| Date | 2015-01-03 19:46 +0000 |
| Message-ID | <9GXpw.291977$Mn4.258606@fx12.iad> |
| In reply to | #55726 |
On 2015-01-03, Jorgen Grahn <grahn+nntp@snipabacken.se> wrote: > On Sun, 2014-12-28, Barry Schwarz wrote: >> On Sat, 27 Dec 2014 22:41:18 -0800 (PST), EQuestionAnswers Inc >> <equestionanswers@gmail.com> wrote: >> >>>Hi, >>> >>>This is our website http://www.equestionanswers.com loaded with C,C++, VC++,MFC,COM,DCOM, >>> DLL question and answers, targeted for interviews and self-study. Hope you like this forum. >> >> Any site that says "Pointer is nothing but an unsigned long number" is >> probably worth avoiding. > > Why is it that idiots try to teach C programming? Don't they have > anything better to do, being silently incompetent or something? > I'm no great programmer or tutor, but even I could do a decent job of > explaining pointers. An expose of historical pointer implementations > would replace that sentence, and explain a hell of a lot more ... > If you ever find yourself on the quora site you might come to the conclusion that people like the sound of their own voice - especailly in written form. -- http://www.softsprocket.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web