Click here to Skip to main content
15,892,768 members
Home / Discussions / C#
   

C#

 
AnswerRe: progress bar while switching to new page Pin
Richard MacCutchan13-Feb-11 22:34
mveRichard MacCutchan13-Feb-11 22:34 
QuestionPolyLib Modifying the ToString method Pin
Ryano12113-Feb-11 5:03
Ryano12113-Feb-11 5:03 
AnswerRe: PolyLib Modifying the ToString method Pin
Eddy Vluggen13-Feb-11 6:03
professionalEddy Vluggen13-Feb-11 6:03 
GeneralRe: PolyLib Modifying the ToString method Pin
Ryano12113-Feb-11 7:43
Ryano12113-Feb-11 7:43 
AnswerRe: PolyLib Modifying the ToString method Pin
Luc Pattyn14-Feb-11 1:03
sitebuilderLuc Pattyn14-Feb-11 1:03 
GeneralRe: PolyLib Modifying the ToString method Pin
Ryano12114-Feb-11 2:22
Ryano12114-Feb-11 2:22 
GeneralMessage Removed Pin
14-Feb-11 2:24
Ryano12114-Feb-11 2:24 
GeneralRe: PolyLib Modifying the ToString method Pin
Luc Pattyn14-Feb-11 2:46
sitebuilderLuc Pattyn14-Feb-11 2:46 
OK, the problem is with the operator signs; it is caused by the non-ideal approach taken originally: there is an if statement trying to look at the next coefficient. It is bound to go wrong when traversing the array in the other direction. And it is plain wrong as is anyway, just imagine a few consecutive coefficients being zero.

The correct approach would implement this rule: each term needs a "+" sign if it hasn't a negative coefficient and isn't the first term in the output. Putting it like that, you don't need to look at other coefficients, you just keep one state variable telling you whether or not this is the first term to be seen.

In pseudo-code:
bool firstTerm=true;
foreach(term in polynomial) {
    if (coef==0) skip;
    if (!firstTerm && coef>0) output("+");
    output(term);
    firstTerm=false;
}


Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

Questionerror in passing value from one form to other Pin
aeman13-Feb-11 1:28
aeman13-Feb-11 1:28 
AnswerRe: error in passing value from one form to other Pin
Wendelius13-Feb-11 1:49
mentorWendelius13-Feb-11 1:49 
AnswerRe: error in passing value from one form to other Pin
Luc Pattyn13-Feb-11 1:52
sitebuilderLuc Pattyn13-Feb-11 1:52 
QuestionPlease can someone do me a favour and run a C# test for me Pin
Dave Midgley12-Feb-11 23:49
Dave Midgley12-Feb-11 23:49 
AnswerRe: Please can someone do me a favour and run a C# test for me Pin
OriginalGriff13-Feb-11 0:36
mveOriginalGriff13-Feb-11 0:36 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
Dave Midgley13-Feb-11 6:05
Dave Midgley13-Feb-11 6:05 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
OriginalGriff13-Feb-11 6:08
mveOriginalGriff13-Feb-11 6:08 
AnswerRe: Please can someone do me a favour and run a C# test for me Pin
PIEBALDconsult13-Feb-11 3:22
mvePIEBALDconsult13-Feb-11 3:22 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
Dave Midgley13-Feb-11 6:06
Dave Midgley13-Feb-11 6:06 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
OriginalGriff13-Feb-11 6:09
mveOriginalGriff13-Feb-11 6:09 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
Richard MacCutchan13-Feb-11 6:24
mveRichard MacCutchan13-Feb-11 6:24 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
PIEBALDconsult13-Feb-11 14:58
mvePIEBALDconsult13-Feb-11 14:58 
AnswerRe: Please can someone do me a favour and run a C# test for me Pin
Dave Kreskowiak13-Feb-11 10:59
mveDave Kreskowiak13-Feb-11 10:59 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
Dave Midgley13-Feb-11 20:19
Dave Midgley13-Feb-11 20:19 
QuestionVariable to be Accessed throughout code [modified] Pin
MWRivera12-Feb-11 16:37
MWRivera12-Feb-11 16:37 
AnswerRe: Variable to be Accessed throughout code Pin
OriginalGriff12-Feb-11 21:21
mveOriginalGriff12-Feb-11 21:21 
GeneralRe: Variable to be Accessed throughout code Pin
MWRivera13-Feb-11 4:07
MWRivera13-Feb-11 4:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.