How to write "decToBin" in Swift? -


i have been looking equivalent javascripts dectobin in swift 2. have not been able find anything. replicate following javascript code code:

var max = 511; var maxlength = dectobin(max).tostring().length; 

you can use string achieve this:

let max       = 511 let maxlength = string(max, radix: 2).characters.count 

you can find more in apple string documentation


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -