Exemple #1
0
 public override string ToString()
 {
     if (Re == 0 && Im == 0)
     {
         return("0");
     }
     else
     if (Re != 0 && Im == 0)
     {
         return(Re.ToString());
     }
     else
     if (Re == 0 && Im != 0)
     {
         return(Im.ToString() + "i");
     }
     else
     if (Im > 0)
     {
         return($"{Re}+{Im}i");
     }
     else
     {
         return($"{Re}{Im}i");
     }
 }
        public override string ToString()
        {
            string retStr;

            if (Math.Abs(Im) < 0.0001)
            {
                retStr = Re.ToString("f4");
            }
            else if (Math.Abs(Re) < 0.0001)
            {
                if (Im > 0)
                {
                    retStr = "j" + Im.ToString("f4");
                }
                else
                {
                    retStr = "-j" + (0 - Im).ToString("f4");
                }
            }
            else
            {
                if (Im > 0)
                {
                    retStr = Re.ToString("f4") + "+j" + Im.ToString("f4");
                }
                else
                {
                    retStr = Re.ToString("f4") + "-j" + (0 - Im).ToString("f4");
                }
            }
            retStr += " ";
            return(retStr);
        }
    // override Object.ToString() as all class by default derived from Object
    // every class gets Object's methods and properties
    public override string ToString()
    {
        if (Im == .0) // smaple: 3
        {
            return(Re.ToString());
        }
        string output = "";

        if (Re != .0)
        {
            output = $"{Re}";
        }
        if (Im < 0) // smaple: -3i
        {
            output += $"-{-Im}i";
        }
        else if (Re == .0) // smaple: 3i
        {
            output += $"{Im}i";
        }
        else // smaple: 3+4i
        {
            output += $"+{Im}i";
        }
        return(output);
    }
        private void button1_Click(object sender, EventArgs e)
        {
            // povikuvanje na site broevi pomali od 0
            const double small = 1E-15;
            double       Re;
            double       Im;

            //presmetka na koren
            List <Complex> Roots = SolveCubic(Coeff.A, Coeff.B, Coeff.C, Coeff.D);

            Re             = Math.Abs(Roots[0].Real) < small ? 0.0 : Roots[0].Real;
            Im             = Math.Abs(Roots[0].Imaginary) < small ? 0.0 : Roots[0].Imaginary;
            X1RealTxb.Text = Re.ToString();
            X1ImagTxb.Text = Im.ToString();

            Re             = Math.Abs(Roots[1].Real) < small ? 0.0 : Roots[1].Real;
            Im             = Math.Abs(Roots[1].Imaginary) < small ? 0.0 : Roots[1].Imaginary;
            X2RealTxb.Text = Re.ToString();
            X2ImagTxb.Text = Im.ToString();

            Re             = Math.Abs(Roots[2].Real) < small ? 0.0 : Roots[2].Real;
            Im             = Math.Abs(Roots[2].Imaginary) < small ? 0.0 : Roots[2].Imaginary;
            X3RealTxb.Text = Re.ToString();
            X3ImagTxb.Text = Im.ToString();
        }
Exemple #5
0
        public string SkrivSomKartesisk()
        {
            string svar = "(";

            if (Re != 0)
            {
                svar = svar + Re.ToString() + " ";
            }
            if (Im >= 0 && Re != 0)
            {
                svar = svar + "+ ";
            }
            else if (Im < 0 && Re != 0)
            {
                svar = svar + "- ";
            }

            svar = svar + Math.Abs(Im).ToString() + "i";

            if (Re == 0 && Im == 0)
            {
                svar = svar + "0";
            }
            svar = svar + ")";
            return(svar);
        }
        public void ReToStringTest()
        {
            var complex = new Complex(3.1, 2.5);
            var exp     = new Re(new ComplexNumber(complex));

            Assert.Equal("re(3.1+2.5i)", exp.ToString(commoonFormatter));
        }
Exemple #7
0
        public void ToStringTest()
        {
            var complex = new Complex(3.1, 2.5);
            var exp = new Re(new ComplexNumber(complex));

            Assert.Equal("re(3.1+2.5i)", exp.ToString());
        }
Exemple #8
0
 public string ToStringFormatted(IFormatSettings format)
 {
     if (format.OmitComplexImPartOfZero && Im == 0)
     {
         return(Re.ToString());
     }
     return(ToString());
 }
        private void txt_SDO1_2_Leave(object sender, EventArgs e)
        {
            double f, sd, Re;

            f  = double.Parse(txt_factor_sueldo.Text);
            sd = double.Parse(txt_SDO1_2.Text);
            Re = f * sd;
            txt_SDO3_2.Text = Re.ToString();
            txt_SDO5_2.Text = Re.ToString();
        }
 public override string ToString()
 {
     if (Im == 0)
     {
         return(Re.ToString());
     }
     if (Re == 0)
     {
         return($"{Im}i");
     }
     return($"{Re}{(Im >= 0 ? "+" : "")}{Im}i");
 }
Exemple #11
0
    public static void AddReRule <TMsg>(this Controller <TMsg> controller, Re re, MatchHandle <TMsg> handle,
                                        ReRuleOptions options = null)
    {
        options ??= new ReRuleOptions();
        if (options.ImplicitBeginEnd)
        {
            re = begin + re + end;
        }
        var regex = new Regex(re.ToString(), options.RegexOptions);

        AddRegexRule(controller, regex, handle);
    }
Exemple #12
0
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        btnPay.Visible = true;
        try
        {
            To = Convert.ToInt32(lblTotalAmtPay.Text);
            Fr = Convert.ToInt32(lblTFromNo.Text);
            Re = Convert.ToInt32(lblReqAmt.Text);
            if (Re <= To)
            {
                lblMessage1.Text       = "Approve All Form " + To.ToString() + " From No." + Fr.ToString() + " Requir " + Re.ToString();
                lblToBeAmount.Text     = Re.ToString();
                lblToBeApprovadNo.Text = Fr.ToString();
            }
            else if (Re > To)
            {
                count = 0;
                Div   = Re / Fr;
                for (int i = 1; i <= Fr + 1; i++)
                {
                    Re = Re - (int)Div;
                    if (Re <= To)
                    {
                        count = count + i;
                        goto outer;
                        //break;
                    }
                    // continue;
                    // Re = Re - (int)Div;
                }
outer:
                if (count > Fr)
                {
                    lblToBeApprovadNo.Text = "0";
                    lblToBeAmount.Text     = "0";
                }
                else
                {
                    lblToBeApprovadNo.Text = (Fr - count).ToString();
                    lblToBeAmount.Text     = ((Fr - count) * Div).ToString();
                }
            }
            int ldf = Convert.ToInt32(lblTotalAmtPay.Text) - Convert.ToInt32(lblToBeAmount.Text);
            lblLTaken.Text = (Convert.ToInt32(lblLTaken.Text) - ldf).ToString();
            lblLRem.Text   = (Convert.ToInt32(lblLRem.Text) + ldf).ToString();
        }
        catch (Exception ex)
        {
            lblMessage1.Text = ex.ToString();
        }
    }
Exemple #13
0
        public override string ToString()
        {
            string result = "0";

            if (Re != 0)
            {
                result = Re.ToString();
            }
            if (Im != 0)
            {
                result = string.Format("{0} {1}i", result, Im > 0 ? "+ " + Im : "- " + Im * -1);
            }
            return(result);
        }
Exemple #14
0
 //-- в строку
 public override string ToString()
 {
     if (Im != 0)
     {
         if (Im > 0)
         {
             return(Re + "+i" + Im);
         }
         else
         {
             return(Re.ToString() + "-i" + Math.Abs(Im));
         }
     }
     else
     {
         return(Re.ToString());
     }
 }
Exemple #15
0
        public override string ToString()
        {
            if (ReferenceEquals(this, Zero))
            {
                return("0");
            }

            string im, sign;

            if (Im < 0)
            {
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                sign = Re == 0 ? "-" : " - ";
            }
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            else if (Im > 0 && Re != 0)
            {
                sign = " + ";
            }
            else
            {
                sign = "";
            }

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            var re = Re == 0 ? "" : Re.ToString(CultureInfo.InvariantCulture);

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (Im == 0)
            {
                im = "";
            }
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            else if (Im == -1 || Im == 1)
            {
                im = "i";
            }
            else
            {
                im = Math.Abs(Im) + "i";
            }

            return(re + sign + im);
        }
Exemple #16
0
        public string UtskriftKartesisk()
        {
            string svar = Re.ToString();

            svar = svar + " ";
            if (Im > 0)
            {
                svar = svar + "+ ";
            }
            else if (Im < 0)
            {
                svar = svar + "- ";
            }

            if (Im != 0)
            {
                svar = svar + Math.Abs(Im).ToString();
                svar = svar + "i";
            }

            return(svar);
        }
Exemple #17
0
 public override string ToString()
 {
     if (Im == 0)
     {
         return(Re.ToString());
     }
     else if (Re == 0)
     {
         return(Im.ToString());
     }
     else if (Im > 0)
     {
         return(Re.ToString() + "+" + Im.ToString() + "i");
     }
     else if (Im < 0)
     {
         return(Re.ToString() + Im.ToString() + "i");
     }
     else
     {
         return("0");
     }
 }
Exemple #18
0
 public override string ToString()
 {
     if (Im != 0)
     {
         if (Re > 0)
         {
             return(Im + "*i+" + Re);
         }
         else
         if (Re < 0)
         {
             return(Im + "*i" + Re);
         }
         else
         {
             return(Im + "*i");
         }
     }
     else
     {
         return(Re.ToString());
     }
 }
Exemple #19
0
 public override string ToString()
 {
     return("(" + Re.ToString("F4") + " ," + Im.ToString("F4") + ")");
 }
Exemple #20
0
 public string ToString(string format, System.IFormatProvider formatProvider)
 {
     return(Re.ToString(format, formatProvider) + (Im < 0 ? " " : " +") + Im.ToString(format, formatProvider) + 'i');
 }
Exemple #21
0
        private void btnEnregistrer_Click(object sender, EventArgs e)
        {
            int Quant, Re;

            if (txtQuantite.Text != "")
            {
                Quant = int.Parse(txtQuantite.Text);
            }
            else
            {
                Quant = 1;
            }
            if (txtRemise.Text != "")
            {
                Re = int.Parse(txtRemise.Text);
            }
            else
            {
                Re = 0;
            }



            BL.D_Commande DETAIL = new BL.D_Commande
            {
                Id       = int.Parse(lblId.Text),
                Nom      = lblNom.Text,
                Quantite = Quant,
                Prix     = lblPrix.Text,
                Remise   = Re.ToString(),
                Total    = txtTotal.Text,
            };
            //ajout liste
            if (lblVendreP.Text == "Vendre Produit")
            {
                if (BL.D_Commande.ListeDetail.SingleOrDefault(s => s.Id == DETAIL.Id) != null)
                {
                    MessageBox.Show("Produit déja existant dans la commande", "Produit", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    BL.D_Commande.ListeDetail.Add(DETAIL);
                }
            }
            else
            {//Modifier
                DialogResult PR = MessageBox.Show("Voulez vous vraiment modifier?", "Modification", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (PR == DialogResult.Yes)
                {
                    int index = BL.D_Commande.ListeDetail.FindIndex(s => s.Id == int.Parse(lblId.Text));
                    BL.D_Commande.ListeDetail[index] = DETAIL;
                    MessageBox.Show("Modification réalisée avec succès", "Modification", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    Close();
                }
                else
                {
                    MessageBox.Show("Modification annulée", "Modification", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }



            //actualisation datagrid
            (frmDetail as FRM_Detail_Commande).Actualiser_DetailCommande();
        }
 public string ToString(string format, System.IFormatProvider formatProvider)
 {
     return(Re.ToString(format, formatProvider) + (Im < 0 ? @" " : @" +") + Im.ToString(format, formatProvider) + @"*i");
 }
 public string ToString(string format)
 {
     return(Re.ToString(format) + (Im < 0 ? @" " : @" +") + Im.ToString(format) + @"*i");
 }