00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 package jpl;
00029
00030 import java.util.Map;
00031
00032 import jpl.fli.DoubleHolder;
00033 import jpl.fli.Prolog;
00034 import jpl.fli.term_t;
00035
00036
00037
00066 public class Float extends Term {
00067
00068
00069
00070
00071
00075 protected final double value;
00076
00077
00078
00079
00080
00087 public Float(double value) {
00088 this.value = value;
00089 }
00090
00091
00092
00093
00094
00100 public final Term arg(int i) {
00101 throw new JPLException("jpl.Float#arg(int) is undefined");
00102 }
00103
00109 public Term[] args() {
00110 return new Term[] {};
00111 }
00112
00118 public final boolean hasFunctor(String name, int arity) {
00119 return false;
00120 }
00121
00127 public final boolean hasFunctor(int val, int arity) {
00128 return false;
00129 }
00130
00136 public final boolean hasFunctor(double val, int arity) {
00137 return val == this.value && arity == 0;
00138 }
00139
00145 public final String name() {
00146 throw new JPLException("jpl.Float#name() is undefined");
00147 }
00148
00154 public final int arity() {
00155 return 0;
00156 }
00157
00163 public final int intValue() {
00164 return (new Double(value)).intValue();
00165 }
00166
00172 public final long longValue() {
00173 return (new Double(value)).longValue();
00174 }
00175
00181 public final float floatValue() {
00182 return (new Double(value)).floatValue();
00183 }
00184
00190 public final double doubleValue() {
00191 return this.value;
00192 }
00193
00194 public final int type() {
00195 return Prolog.FLOAT;
00196 }
00197
00198 public String typeName(){
00199 return "Float";
00200 }
00201
00207 public String toString() {
00208 return "" + value + "";
00209 }
00210
00217 public final boolean equals(Object obj) {
00218 return this == obj || (obj instanceof Float && value == ((Float) obj).value);
00219 }
00220
00221 public Object jrefToObject() {
00222 throw new JPLException("Float.jrefToObject: term is not a JRef");
00223 }
00224
00225
00226
00227
00228
00235 public double value() {
00236 return value;
00237 }
00238
00245 public String debugString() {
00246 return "(Float " + toString() + ")";
00247 }
00248
00249
00250
00251
00252
00261 protected final void put(Map varnames_to_vars, term_t term) {
00262 Prolog.put_float(term, value);
00263 }
00264
00265
00266
00267
00268
00276 protected static Term getTerm1(Map vars_to_Vars, term_t term) {
00277 DoubleHolder double_holder = new DoubleHolder();
00278
00279 Prolog.get_float(term, double_holder);
00280 return new jpl.Float(double_holder.value);
00281 }
00282
00283
00284
00285
00286
00293 protected final void getSubst(Map varnames_to_Terms, Map vars_to_Vars) {
00294 }
00295
00296 }
00297
00298