Anonymous user
Non-decimal radices/Convert: Difference between revisions
→{{header|Swift}}
(Hello, I'm a 12 year old boy. I have posted the Scratch solution to this problem online.) |
|||
Line 1,969:
=={{header|Swift}}==
Converting integer to string
<lang swift>println(String(26, radix: 16)) // prints "1a"</
Converting
<lang swift>
func string2int(s: String, radix: Int) -> Int {
return
// there is also strtoul() for UInt, and strtoll() and strtoull() for Int64 and UInt64, respectively
}
println(string2int("1a", 16)) // prints "26"</lang>
|