All pastes #189070 Raw Edit

Stuff

public java v1 · immutable
·published 2006-10-02 19:47 UTC
rendered paste body
public class DoubleStringer{    public static double StringToDouble(String str)    {        double multiplier = 1.;        if (str.charAt(0) == '-')        {            multiplier = -1.;            str = str.substring(1);        }        if (str.charAt(0) == '+')            str = str.substring(1);        String before, after = "";        int decimal = str.indexOf('.');        if(decimal > -1)        {            before = str.substring(0,decimal);            after = str.substring(decimal+1);        }        else            before = str;                ////the cool loop way        //double temp = 0.;        //int i;        //for(i = before.length(); i > 0; i--)        //    temp += Integer.parseInt(before.substring(i-1,i)) * Math.pow(10,before.length()-i);        //for(i = 0; i < after.length(); i++)        //    temp += Integer.parseInt(after.substring(i,i+1)) * Math.pow(.1,i+1);                ////the lame way        double temp = Integer.parseInt(before) + Integer.parseInt(after) * Math.pow(.1,after.length());                return multiplier * temp;    }}