Hi. I'm trying to convert numbers between decimal, binary, octal and hex.
I've made a little Playground to explore.
Code is this:
I seem to be getting garbage responses, including this crash:
People can play with this code. Please let me know or what to do.
Many thanks
I've made a little Playground to explore.
Code is this:
Code Block let myNumber = "12345" let myBinary = (UInt8(myNumber, radix: 2) != nil) print(myBinary) let myOctal = Int(myNumber, radix: 8) print(myOctal!) let myHex = Int(myNumber, radix: 16) print(myHex!) let h2 = "27" let d4 = Int(h2, radix: 2)! print(d4)
I seem to be getting garbage responses, including this crash:
Code Block false 5349 74565 Fatal error: Unexpectedly found nil while unwrapping an Optional value: file __lldb_expr_60/Playground4.playground, line 16 Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
People can play with this code. Please let me know or what to do.
Many thanks