 ## 5 replies

Last post Aug 03, 2017 08:44 AM by MuhammadNaveedHaroon

• ### substract formula in asp.net

anyone?

here's my code:

r1 = 8
r2 = 0
r3 = 8

double t1= Convert.ToDouble(r1) - Convert.ToDouble(r2);
double t2= Convert.ToDouble(r2) - Convert.ToDouble(r3);
double t3= Convert.ToDouble(t1) + Convert.ToDouble(t2);

t1 = 8

t2 = -8

i want to remove the -8 in t2

• ### Re: substract formula in asp.net

Hi,

This is -= rarher than =- (currently you assign -8). See a reference such as:

• ### Re: substract formula in asp.net

Perhaps you want the absolute value?

```        static void Main(string[] args)
{

String r1 = "8";
String r2 = "0";
String r3 = "8";

Double t1 = Convert.ToDouble(r1) - Convert.ToDouble(r2);
Double t2 = Math.Abs(Convert.ToDouble(r2) - Convert.ToDouble(r3));
Double t3 = Convert.ToDouble(t1) + Convert.ToDouble(t2);

Console.WriteLine(t1);
Console.WriteLine(t2);
Console.WriteLine(t3);
}```
```8
8
16
```

• ### Re: substract formula in asp.net

Aug 02, 2017 02:27 AM|Cathy Zou|LINK

Hi  paminchever

``` Double t1 = Convert.ToDouble(r1) - Convert.ToDouble(r2);
Double t2 = Convert.ToDouble(r2) - Convert.ToDouble(r3);
if (t2 < 0)
{
//t2 = t2 * (-1);
t2 = -t2;
}
Double t3 = Convert.ToDouble(t1) + Convert.ToDouble(t2);```

Best regards

Cathy

MSDN Community Support
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
• ### Re: substract formula in asp.net

#### paminchever

i want to remove the -8 in t2
What do you mean by this?

There is no concept of 'remove' for a variable of this type.

Do you want something else stored in t2?  Tell us what you want.

Do you want to release the memory used by the t2 variable? (There probably isn't any)

Do you want to not create the t2 variable at all?