Timeline for What is the size of the number 65535 in bytes?
Current License: CC BY-SA 4.0
17 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 1, 2021 at 21:36 | comment | added | treesarecool | Thank you for this amazing and interesting answer @Flater! I appreciate the time you spent on this explanation and am very thankful for it! | |
Sep 1, 2021 at 21:20 | vote | accept | treesarecool | ||
Aug 31, 2021 at 7:28 | comment | added | Flater | @GlenYates "However, int is always 4 bytes" What I meant by this is that the size of the allocated memory does not change based on how many digits your specific numerical value needs (e.g. 14 needs 4 bits, 126 needs 7 bits, ...). OP's question seems very much rooted in the idea that there is an intelligent decision making about dynamic allocation sizes that minimize data footprint. While ints are not all 4 bytes in every system, their size in a given system is fixed. For the imprecision of not accounting for all possible systems, I refer back to my previous comment (two up from here). | |
Aug 31, 2021 at 0:43 | comment | added | David Z | FWIW I think this is a well-written answer considering the level of expertise indicated in the question, and it was a smart decision to keep the answer simple, even at the expense of getting things right in the edge cases. | |
Aug 30, 2021 at 22:44 | comment | added | Flater | I understand the drive to correct little imperfections in the answer, but this answer is kept simple specifically because it's addressed at a layman. The finer details do not help explain the core focus and edge cases are unnecessarily distracting to get the main message across. I do agree that my explanation is not 100% correct, but the omissions it makes are done to boil the answer down to the topic at hand and keep it as simple as it reasonably can be. | |
Aug 30, 2021 at 20:57 | comment | added | TCooper | @Flater submitted an edit to address Mr. Yates edge case, won't be offended if it's rejected though. Great, thorough explanation! | |
Aug 30, 2021 at 20:56 | review | Suggested edits | |||
Aug 30, 2021 at 22:41 | |||||
Aug 30, 2021 at 19:27 | comment | added | Mark Rotteveel | Minor nitpick: ASCII defines 128 values, 0 - 127. | |
Aug 30, 2021 at 16:28 | comment | added | Peter Cordes |
@GlenYates: Perhaps "int is always fixed width on any given machine; assuming a 4-byte int it gets stored as ..." (machine isn't quite accurate, you could have different C implementations on the same machine, but a lot closer to correct without making the phrasing too much more verbose.) Unless we're talking about other languages where int is fixed-width 4 bytes, which might be the case in this answer because C doesn't have a uint type.
|
|
Aug 30, 2021 at 16:18 | comment | added | Glen Yates | "However, int is always 4 bytes" This is not true, my 16-bit microcontroller begs to differ! | |
Aug 30, 2021 at 14:58 | comment | added | Seth R |
The validity of string myStringPlusOne = myString + 1; also depends on what language/compiler you are using. Some compilers will happily implicitly convert that 1 to a character-type because you are clearly working with a String type and will assume that's what you meant. Others will give you an error because mixing character-types and numeric-types is not allowed. To reinforce your point: they're different data types.
|
|
Aug 30, 2021 at 12:37 | comment | added | Flater | @Sulthan: Yep. I only went with ASCII here for simplicity's sake as its shorter set of characters makes it easier to parse when discussing the underlying binary data. | |
Aug 30, 2021 at 12:04 | comment | added | Sulthan | To be more precise, ASCII is just one encoding for a specific character set. Nowadays ASCII is used only rarely but it is a subset of UTF8 encoding for Unicode charset. | |
Aug 30, 2021 at 8:28 | history | edited | Flater | CC BY-SA 4.0 |
added 21 characters in body
|
Aug 30, 2021 at 8:19 | history | edited | Flater | CC BY-SA 4.0 |
added 1559 characters in body
|
Aug 30, 2021 at 8:12 | history | edited | Flater | CC BY-SA 4.0 |
added 1559 characters in body
|
Aug 30, 2021 at 7:59 | history | answered | Flater | CC BY-SA 4.0 |