Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rational.py
diff options
context:
space:
mode:
Diffstat (limited to 'rational.py')
-rw-r--r--rational.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/rational.py b/rational.py
index 564d4d9..381b05a 100644
--- a/rational.py
+++ b/rational.py
@@ -130,3 +130,10 @@ class Rational:
self.n = abs(self.n)
self.d = abs(self.d)
+ def __pow__(self, rval):
+ if type(rval) is types.IntType or type(rval) is types.LongType:
+ ret = Rational(self.n ** rval, self.d ** rval)
+ else:
+ ret = float(self.n) ** rval / float(self.d) ** rval
+
+ return ret