[Python-checkins] r55138 - python/branches/decimal-branch/Lib/decimal.py
Neal Norwitz
nnorwitz at gmail.com
Sat May 5 01:09:42 CEST 2007
On 5/4/07, facundo.batista <python-checkins at python.org> wrote:
> Author: facundo.batista
> Date: Fri May 4 23:00:49 2007
> New Revision: 55138
>
> Modified:
> python/branches/decimal-branch/Lib/decimal.py
> Log:
>
> Added a private function _islogical(), which determines if the
> operand is a logical one or not. Also coded the logical_invert()
> operation, which passes all tests ok.
>
>
> Modified: python/branches/decimal-branch/Lib/decimal.py
> ==============================================================================
> --- python/branches/decimal-branch/Lib/decimal.py (original)
> +++ python/branches/decimal-branch/Lib/decimal.py Fri May 4 23:00:49 2007
> @@ -2429,11 +2429,53 @@
> without limiting the resulting exponent).
> """
>
> + def _islogical(self):
> + """Return 1 is self is a logical operand.
> +
> + For being logical, it must be a finite numbers with a sign of 0,
> + an exponent of 0, and a coefficient whose digits must all be
> + either 0 or 1.
> + """
> + if self._sign != 0 or self._exp != 0:
> + return 0
> + for dig in self._int:
> + if dig not in (0, 1):
> + return 0
> + return 1
Why not use a boolean instead of 0/1?
n
More information about the Python-checkins
mailing list