Re: Change a double value
Show us what you've got and where you're getting errors/unexpected results.
Re: Change a double value
I am not getting any results yet, because I am not sure how to do it...
Code:
Double value1 = -150.00;
If this value is negative, like this example, I would like to make a new value like this:
Code:
Double value2 = 150.00;
And vice versa....
Re: Change a double value
will switch it from negative to positive and vice versa.
Re: Change a double value
Code:
String Amount = textAmount.getText();
Amount = Amount.replace(" ", "");
Amount = Amount.replace(",", ".");
double amount;
if (!"".equals(Amount))
{
amount = Double.parseDouble(Amount);
}else{
amount = 0;
}
double amount2 = * -amount;
But I get an error:
Code:
illegal start of expression
Re: Change a double value
The *(asterisk) has to be in front of the =(equals)
Code:
// +150.00
double amount1 = 150.0;
//-150.00
double amount2 = amount1 * -1;
Re: Change a double value
Code:
String Amount = textAmount.getText();
Amount = Amount.replace(" ", "");
Amount = Amount.replace(",", ".");
double amount;
if (!"".equals(Amount))
{
amount = Double.parseDouble(Amount);
}else{
amount = 0;
}
double amount2 = amount * -1;
Work perfect. Thanks JBelg!! :(y):