Im confused on why byte size matters when assigning numbers. What is the purpose of long, double, etc. that affects byte size. What is byte sizes significance. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Im confused on why byte size matters when assigning numbers. What is the purpose of long, double, etc. that affects byte size. What is byte sizes significance.

18th May 2017, 2:28 PM
Mark
7 Answers
+ 11
it is about the range that you can represent a data type. example: int 32,768 to +32,767 long int −2,147,483,648 to +2,147,483,647 this link can help you: https://www.tutorialspoint.com/cplusplus/cpp_data_types.htm
18th May 2017, 2:48 PM
Mohammad Dakdouk
Mohammad Dakdouk - avatar
+ 4
Numbers are stored as bytes, which are made of bits. As an example, say you have an unsigned byte. The largest integer you could store in it is only 255. This is why size matters. The more bytes you have, the larger the number you can store. (Or more numbers after the decimal in the case of floats and doubles.) Another reason why size matters is how much memory it takes up. If you have 100 chars, it only takes up 100 bytes of memory on win32/64. If you have 100 ints, that will take up 400 bytes which is 4x more memory.
18th May 2017, 3:17 PM
aklex
aklex - avatar
+ 4
@Setiawan it's not about speed, it's about memory capacity.
18th May 2017, 7:02 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
More bytes can represent larger numbers or more precise values. Less bytes is effective. It needs smaller space and computation.
18th May 2017, 2:44 PM
Twelfty
Twelfty - avatar
+ 1
Thank you guys so much, limk was super helpful
18th May 2017, 3:36 PM
Mark
0
*link
18th May 2017, 3:36 PM
Mark
- 2
in short, to make it run faster. That is the advantage using C++. If you use PHP or Javascript you don't have to care about data type.
18th May 2017, 2:39 PM
Setiawan Next
Setiawan Next - avatar