Message313912
Observed by Terry Reedy in the issue #25735 discussion (msg255479):
>>> factorial(decimal.Decimal(5.2))
120
This should be either raising an exception (either ValueError or TypeError, depending on whether we want to accept only integral Decimal values, or prohibit Decimal values altogether), or possibly returning an approximation to Gamma(6.2) (=169.406099461722999629...)
I'd prefer that we prohibit a Decimal input altogether, but accepting integral Decimal instances would parallel the current behaviour with floats:
>>> factorial(5.2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: factorial() only accepts integral values
>>> factorial(5.0)
120
Terry also observed:
>>> factorial(Fraction(5))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: an integer is required (got type Fraction) |
|
| Date |
User |
Action |
Args |
| 2018-03-15 20:38:33 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, terry.reedy, facundobatista, skrah |
| 2018-03-15 20:38:33 | mark.dickinson | set | messageid: <1521146313.09.0.467229070634.issue33083@psf.upfronthosting.co.za> |
| 2018-03-15 20:38:33 | mark.dickinson | link | issue33083 messages |
| 2018-03-15 20:38:32 | mark.dickinson | create | |
|