the return value is the converted value to or from base
"""
-
-import evil_globals
+# For the sake of eval'ing some code
+import math
# used for Computer numbers base definitions.
'xv'
"""
if n < 0:
- raise NotImplemented("Value out of roman comprehension")
+ raise NotImplementedError("Value out of roman comprehension")
elif n == 0:
''
elif n >= 4000:
- raise NotImplemented("Value Out of Range")
+ raise NotImplementedError("Value Out of Range")
base = 1
s = ''
position = len(value) #length of the string that is to be converted
for x in value:
position = position-1
- result = long(result + long(long(string.find(ALPHA_NUMERIC,x))*(long(base)**long(position))))
+ result = long(result + long(long(ALPHA_NUMERIC.find(x))*(long(base)**long(position))))
return result
def from_base(self,value,base):
#value is assumed to be a string
#convert from a defined function to base
def to_base(self,value,(to_base,from_base)):
- exec "y="+to_base[:string.find(to_base,'x')]+str(value)+to_base[string.find(to_base,'x')+1:]
+ exec "y="+to_base[:to_base.find('x')]+str(value)+to_base[to_base.find('x')+1:]
return y
def from_base(self,value,(to_base,from_base)):
- exec "y="+from_base[:string.find(from_base,'x')]+str(value)+from_base[string.find(from_base,'x')+1:]
+ exec "y="+from_base[:from_base.find('x')]+str(value)+from_base[from_base.find('x')+1:]
return y