'Why decimal.Decimal(0)**decimal.Decimal(0) doesn't return 1
Why does decimal.Decimal(0)**decimal.Decimal(0) not return 1 but an error?
import decimal
decimal.Decimal(0)**5 # works and returns Decimal('0') as it should
decimal.Decimal(0)**0 # doesn't not work and should return 1
decimal.Decimal(0)**decimal.Decimal(0) # same
0**0 # works and returns 1
I could use if statements to bypass the error I get (decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]) but it looks quite dirty to do so.
EDIT : I've always learned in school that 0^0 was 1 but (cf. comments) it is not. So if I want it to be 1 I guess I'll do it manually (in my case that's the desired behaviour), I wasn't aware there was debate as to its value.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
