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
Post a Comment