Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Int and Uint8 swift

What are the differences between the data types Int & UInt8 in swift.

Looks like UInt8 is used for binary data, i need to convert UInt8 to Int is this possible.

like image 450
nuteron Avatar asked Jun 11 '17 07:06

nuteron


2 Answers

That U in UInt stands for unsigned int.

It is not just using for binary data. Uint is used for positive numbers only, like natural numbers. I recommend you to get to know how negative numbers are understood from a computer.

like image 130
ebug38 Avatar answered Sep 22 '22 07:09

ebug38


Int8 is an Integer type which can store positive and negative values.

UInt8 is an unsigned integer which can store only positive values.

You can easily convert UInt8 to Int8 but if you want to convert Int8 to UInt8 then make sure value should be positive.

like image 35
Piyush Avatar answered Sep 24 '22 07:09

Piyush