/** * Returns either {@link PyObject#__tojava__(java.lang.Class)} with * {@link java.lang.Number}.class as argument. If that fails, returns * {@link PyObject#__float__()}. */ public Number getAsNumber() throws TemplateModelException { try { Object value = object.__tojava__(java.lang.Number.class); if (value == null || value == Py.NoConversion) { return Double.valueOf(object.__float__().getValue()); } return (Number) value; } catch (PyException e) { throw new TemplateModelException(e); } } }
public PyFloat __float__() { return py().__float__(); } public PyObject __long__() { return py().__long__(); }
private void parse_save_field() { PyObject field; field = new PyString(this.field.toString()); if (numeric_field) { numeric_field = false; field = field.__float__(); } fields.append(field); // XXX: fastest way to clear StringBuffer? this.field = new StringBuffer(INITIAL_BUILDER_CAPACITY); }
@ExposedMethod @Override public PyFloat __float__() { return getValue().__float__(); }
/** * Returns either {@link PyObject#__tojava__(java.lang.Class)} with * {@link java.lang.Number}.class as argument. If that fails, returns * {@link PyObject#__float__()}. */ public Number getAsNumber() throws TemplateModelException { try { Object value = object.__tojava__(java.lang.Number.class); if (value == null || value == Py.NoConversion) { return Double.valueOf(object.__float__().getValue()); } return (Number) value; } catch (PyException e) { throw new TemplateModelException(e); } } }
/** * Returns either {@link PyObject#__tojava__(java.lang.Class)} with * {@link java.lang.Number}.class as argument. If that fails, returns * {@link PyObject#__float__()}. */ public Number getAsNumber() throws TemplateModelException { try { Object value = object.__tojava__(java.lang.Number.class); if (value == null || value == Py.NoConversion) { return Double.valueOf(object.__float__().getValue()); } return (Number) value; } catch (PyException e) { throw new TemplateModelException(e); } } }
return arg.__float__();
/** * Returns either {@link PyObject#__tojava__(java.lang.Class)} with * {@link java.lang.Number}.class as argument. If that fails, returns * {@link PyObject#__float__()}. */ public Number getAsNumber() throws TemplateModelException { try { Object value = object.__tojava__(java.lang.Number.class); if(value == null || value == Py.NoConversion) { return new Double(object.__float__().getValue()); } return (Number)value; } catch(PyException e) { throw new TemplateModelException(e); } } }
/** * Convert this object into a double. Throws a PyException on failure. * * @return a double value */ public double asDouble() { PyFloat floatObj; try { floatObj = __float__(); } catch (PyException pye) { if (pye.match(Py.AttributeError)) { throw Py.TypeError("a float is required"); } throw pye; } return floatObj.asDouble(); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rtruediv___doc) final PyObject int___rtruediv__(PyObject left) { if (left instanceof PyInteger) { return left.__float__().__truediv__(this); } else if (left instanceof PyLong) { return left.__truediv__(int___long__()); } else { return null; } }
if (y.compareTo(BigInteger.ZERO) < 0) { if (value.compareTo(BigInteger.ZERO) != 0) { return left.__float__().__pow__(right, modulo); } else { throw Py.ZeroDivisionError("zero to a negative power");
return __float__().asDouble(); } catch (PyException pye) { if (!pye.match(Py.AttributeError)) {
public PyFloat __float__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__float__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyFloat) return(PyFloat)res; throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); } return super.__float__(); }
PyFloat floatObject = null; try { floatObject = x.__float__(); } catch (PyException e) { if (e.match(Py.AttributeError)) {
case QUOTE_NONNUMERIC: try { field.__float__(); } catch (PyException ex) { quoted = true;
return left.__float__().__pow__(right, modulo); } else { throw Py.ZeroDivisionError("0.0 cannot be raised to a negative power");