Revision: 1.1 - (view) (download) (as text)
1 : | ktanaka | 1.1 | // |
2 : | // | ||
3 : | // | ||
4 : | final public class Flonum extends LispObject{ | ||
5 : | double val; | ||
6 : | Flonum(double val){ this.val=val; } | ||
7 : | Flonum(String name){ | ||
8 : | int index=name.indexOf('^'); | ||
9 : | double pow=0.0; | ||
10 : | if(index!= -1){ | ||
11 : | pow=new Double(name.substring(index+1)).doubleValue(); | ||
12 : | name=name.substring(0,index); | ||
13 : | } | ||
14 : | this.val=new Double(name).doubleValue()*Math.pow(10,pow); | ||
15 : | } | ||
16 : | public int getType(){ return FLONUM; } | ||
17 : | public double getVal(){ return val; } | ||
18 : | public String toString(){ return ""+val; } | ||
19 : | public static boolean isFlonumString(String name){ | ||
20 : | int index=name.indexOf('^'); | ||
21 : | if(index!= -1){ | ||
22 : | if(!Fixnum.isFixnumString(name.substring(index+1))) return false; | ||
23 : | name=name.substring(0,index); | ||
24 : | } | ||
25 : | index=name.indexOf('.'); | ||
26 : | if(index!= -1){ | ||
27 : | if(name.length()==1) return false; | ||
28 : | if(!Fixnum.isFixnumString(name.substring(index+1))) return false; | ||
29 : | name=name.substring(0,index); | ||
30 : | } | ||
31 : | if(!Fixnum.isFixnumString(name)) return false; | ||
32 : | return true; | ||
33 : | } | ||
34 : | } |
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |