+ 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.
7 Respostas
+ 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
+ 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.
+ 4
@Setiawan it's not about speed, it's about memory capacity.
+ 1
More bytes can represent larger numbers or more precise values.
Less bytes is effective. It needs smaller space and computation.
+ 1
Thank you guys so much, limk was super helpful
0
*link
- 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.