Having some issues converting a binary string to a Int.
The int value:
-294155939
The int value as binary:
11101110011101111000100101011101
The way im currently converting the binary to an int is like this
Int("11101110011101111000100101011101", radix:2) -> 4000811357
Int32("11101110011101111000100101011101", radix:2) -> nil
Int64("11101110011101111000100101011101", radix:2) -> 4000811357
I also tried UInt, obviously this didn't give the correct output as as UInt is unsigned and cant go below 0.
UInt("11101110011101111000100101011101", radix:2) -> 4000811357
Im unsure why my int representation of the binary string is coming out how it is. Is there another way to convert the binary to a signed int?
Int(Int32(bitPattern: UInt32("11101110011101111000100101011101", radix:2)!))