two = Integer.parseInt(priceperlitrestring.substring(2,3));
if (priceperlitrestring.substring(1,2)==".")
one = Integer.parseInt(priceperlitrestring.substring(0,1));
two = Integer.parseInt(priceperlitrestring.substring(2,3));
three = Integer.parseInt(priceperlitrestring.substring(3,4));
four = 0;
if (priceperlitrestring.substring(1,2)==".") {
one = Integer.parseInt(priceperlitrestring.substring(0,1));
two = Integer.parseInt(priceperlitrestring.substring(2,3));
three = Integer.parseInt(priceperlitrestring.substring(3,4));
four = 0;
}
Why are the numbers stored as Strings? If you have them as floats or whatever a dynamic cast to an int should be adequate.
I need to select specific digits from them.
int getDigit(double number, int digit)
{
return (int)(number * Math.pow(10, digit)) % 10;
}
The problem is I won't know at the time whether there will be 3 or 6 digits in a number, so if say digit 5 is set to -2 and there isn't 2 digits after the decimal point won't that result in an exception?
It would make better sense for the sevensegmentdisplay (which for semantics sake should be SevenSegmentDisplay) to accept a float and the conversion occur within the object.It has to be an integer because it's for a seven segment display.