func transition(fromBase:Int, toBase:Int, beforeNum:String) throws -> String{
if((fromBase<2 || 36<fromBase || toBase<2 || 36<toBase)){
throw NSError(domain: "bigNum", code: -1, userInfo: nil)
}else if(Int(beforeNum, radix: fromBase) == nil){
throw NSError(domain: "bigNum", code: -1, userInfo: nil)
}else if(beforeNum.isEmpty){
throw NSError(domain: "bigNum", code: -1, userInfo: nil)
}
return String(Int(beforeNum, radix: fromBase)!, radix:toBase)
}
网友评论