Initial revision
// // // final public class Flonum extends LispObject{ double val; Flonum(double val){ this.val=val; } Flonum(String name){ int index=name.indexOf('^'); double pow=0.0; if(index!= -1){ pow=new Double(name.substring(index+1)).doubleValue(); name=name.substring(0,index); } this.val=new Double(name).doubleValue()*Math.pow(10,pow); } public int getType(){ return FLONUM; } public double getVal(){ return val; } public String toString(){ return ""+val; } public static boolean isFlonumString(String name){ int index=name.indexOf('^'); if(index!= -1){ if(!Fixnum.isFixnumString(name.substring(index+1))) return false; name=name.substring(0,index); } index=name.indexOf('.'); if(index!= -1){ if(name.length()==1) return false; if(!Fixnum.isFixnumString(name.substring(index+1))) return false; name=name.substring(0,index); } if(!Fixnum.isFixnumString(name)) return false; return true; } }
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |