How to compute min and max of two mpf numbers?

59 views
Skip to first unread message

Allen Rabinovich

unread,
Nov 1, 2012, 11:39:23 PM11/1/12
to mpm...@googlegroups.com
A beginner mpmath question here: how do I compute a min (or a max) of two mpf numbers? Is just the regular python min(a,b) the answer? Why does that work properly, given that mpf's are their own datatypes, and min relies on standard comparison operators?

Fredrik Johansson

unread,
Nov 2, 2012, 3:09:14 AM11/2/12
to mpm...@googlegroups.com
Yes, min(a,b) works fine. It works because mpmath classes provide
comparison methods (__ge__, __gt__, etc.) so that the standard
comparison operators (>=, >, etc.) can be used. This is standard for
custom numeric types in Python.

Fredrik
Reply all
Reply to author
Forward
0 new messages