Author: Amaury Forgeot d'Arc <[email protected]>
Branch: decimal-libmpdec
Changeset: r73806:f9ce042d71da
Date: 2014-09-28 21:39 +0200
http://bitbucket.org/pypy/pypy/changeset/f9ce042d71da/
Log: Progress
diff --git a/pypy/module/_decimal/interp_decimal.py
b/pypy/module/_decimal/interp_decimal.py
--- a/pypy/module/_decimal/interp_decimal.py
+++ b/pypy/module/_decimal/interp_decimal.py
@@ -580,6 +580,10 @@
context = interp_context.ensure_context(space, w_context)
return space.wrap(bool(rmpdec.mpd_issubnormal(self.mpd, context.ctx)))
+ def conjugate_w(self, space):
+ context = interp_context.getcontext(space)
+ return decimal_from_decimal(space, None, self, context, exact=True)
+
def as_tuple_w(self, space):
"Return the DecimalTuple representation of a Decimal"
w_sign = space.wrap(rmpdec.mpd_sign(self.mpd))
@@ -1163,8 +1167,15 @@
max = make_binary_method('mpd_qmax'),
max_mag = make_binary_method('mpd_qmax_mag'),
min = make_binary_method('mpd_qmin'),
+ min_mag = make_binary_method('mpd_qmin_mag'),
next_toward = make_binary_method('mpd_qnext_toward'),
remainder_near = make_binary_method('mpd_qrem_near'),
+ logical_and = make_binary_method('mpd_qand'),
+ logical_or = make_binary_method('mpd_qor'),
+ logical_xor = make_binary_method('mpd_qxor'),
+ rotate = make_binary_method('mpd_qrotate'),
+ scaleb = make_binary_method('mpd_qscaleb'),
+ shift = make_binary_method('mpd_qshift'),
# Ternary arithmetic functions, optional context arg
fma = interp2app(W_Decimal.fma_w),
# Boolean functions, no context arg
@@ -1179,6 +1190,8 @@
# Boolean functions, optional context arg
is_normal = interp2app(W_Decimal.is_normal_w),
is_subnormal = interp2app(W_Decimal.is_subnormal_w),
+ # Unary functions, no context arg
+ conjugate = interp2app(W_Decimal.conjugate_w),
# Binary functions, optional context arg for conversion errors
compare_total = make_binary_method_noctx('mpd_compare_total'),
compare_total_mag = make_binary_method_noctx('mpd_compare_total_mag'),
diff --git a/pypy/module/_decimal/test/test_decimal.py
b/pypy/module/_decimal/test/test_decimal.py
--- a/pypy/module/_decimal/test/test_decimal.py
+++ b/pypy/module/_decimal/test/test_decimal.py
@@ -335,6 +335,7 @@
d = Decimal("2.34")
assert d.real == d
assert d.imag == 0
+ assert d.conjugate() == d
def test_operations(self):
Decimal = self.decimal.Decimal
diff --git a/rpython/rlib/rmpdec.py b/rpython/rlib/rmpdec.py
--- a/rpython/rlib/rmpdec.py
+++ b/rpython/rlib/rmpdec.py
@@ -63,6 +63,7 @@
"mpd_qexp", "mpd_qln", "mpd_qlog10", "mpd_qlogb",
"mpd_qsqrt", "mpd_qinvert",
"mpd_qand", "mpd_qor", "mpd_qxor",
+ "mpd_qrotate", "mpd_qscaleb", "mpd_qshift",
"mpd_qcopy_sign", "mpd_qcopy_abs", "mpd_qcopy_negate",
"mpd_qround_to_int", "mpd_qround_to_intx",
"mpd_parse_fmt_str", "mpd_qformat_spec", "mpd_validate_lconv",
@@ -406,6 +407,16 @@
[MPD_PTR, MPD_PTR, rffi.UINTP],
lltype.Void)
+mpd_qrotate = external(
+ 'mpd_qrotate',
+ [MPD_PTR, MPD_PTR, MPD_PTR, MPD_CONTEXT_PTR, rffi.UINTP], lltype.Void)
+mpd_qscaleb = external(
+ 'mpd_qscaleb',
+ [MPD_PTR, MPD_PTR, MPD_PTR, MPD_CONTEXT_PTR, rffi.UINTP], lltype.Void)
+mpd_qshift = external(
+ 'mpd_qshift',
+ [MPD_PTR, MPD_PTR, MPD_PTR, MPD_CONTEXT_PTR, rffi.UINTP], lltype.Void)
+
mpd_qround_to_int = external(
'mpd_qround_to_int', [MPD_PTR, MPD_PTR, MPD_CONTEXT_PTR, rffi.UINTP],
lltype.Void)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit