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 -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -