return out

    def abs(self, space):
        return W_FloatObject(abs(self.floatval))

    def overflow_convert(self, space):
        return space.wrap(self.float_w(space))

    def eval_static(self, space):
        return self

    def serialize(self, space, builder, memo):
        prec = memo.serialize_precision
        if prec == 0:
            prec = (space.int_w(
                space.ec.interpreter.config.get_ini_w('serialize_precision'))
                or 17)
            memo.serialize_precision = prec
        builder.append("d:")
        builder.append(self._repr(prec=prec))
        builder.append(";")
        return True


for _name in BINOP_LIST:
    if hasattr(W_FloatObject, _name):
        continue
    setattr(W_FloatObject, _name, _new_binop(W_FloatObject, _name,
                                             'floatval',
                                             _name in BINOP_COMPARISON_LIST))
Exemple #2
0
        try:
            z = ovfcheck(x * y)
        except OverflowError:
            return space.newfloat(float(x) * float(y))
        return W_IntObject(z)

    def overflow_convert(self, space):
        return self

    def serialize(self, space, builder, memo):
        builder.append("i:")
        builder.append(str(self.intval))
        builder.append(";")
        return True

    def ll_serialize(self, builder):
        builder.append("i")
        builder.append(struct.pack("l", self.intval))

    def eval_static(self, space):
        return self


for _name in BINOP_LIST:
    if hasattr(W_IntObject, _name):
        continue
    setattr(
        W_IntObject, _name,
        _new_binop(W_IntObject, _name, 'intval', _name
                   in BINOP_COMPARISON_LIST))
Exemple #3
0
            return "%s" % inf.upper()
        if isnan(self.floatval):
            return "NAN"
        out = "%s%s%s" % (indent, self.str(space), suffix)
        return out

    def abs(self, space):
        return W_FloatObject(abs(self.floatval))

    def overflow_convert(self, space):
        return space.wrap(self.float_w(space))

    def eval_static(self, space):
        return self

    def serialize(self, space, builder, memo):
        prec = space.int_w(
            space.ec.interpreter.config.get_ini_w('serialize_precision')) or 17
        _str = self._repr(prec=prec)
        builder.append("d:%s;" % _str)
        return True


for _name in BINOP_LIST:
    if hasattr(W_FloatObject, _name):
        continue
    setattr(
        W_FloatObject, _name,
        _new_binop(W_FloatObject, _name, 'floatval', _name
                   in BINOP_COMPARISON_LIST))
Exemple #4
0
    def mul(self, space, w_other):
        assert isinstance(w_other, W_IntObject)
        x = self.intval
        y = w_other.intval
        try:
            z = ovfcheck(x * y)
        except OverflowError:
            return space.newfloat(float(x) * float(y))
        return W_IntObject(z)

    def overflow_convert(self, space):
        return self

    def serialize(self, space, builder, memo):
        builder.append("i:%d;" % self.intval)
        return True

    def ll_serialize(self, builder):
        builder.append("i")
        builder.append(struct.pack("l", self.intval))

    def eval_static(self, space):
        return self


for _name in BINOP_LIST:
    if hasattr(W_IntObject, _name):
        continue
    setattr(W_IntObject, _name, _new_binop(W_IntObject, _name, "intval", _name in BINOP_COMPARISON_LIST))