-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[DOC] Vagueness in data types explanation #3797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not quite sure if I understand you question correctly - AFAIK, on most 8bit cpus (edited) on 32 bit system even moreover, Because all these values are ambiguous I'm only using the exact-size values for char in strings to be used for Serial it's not possible though: This indeed is a bug. |
Well, I'll rewrite the issue putting "?" where I consider there's no a clear statement. char : 1 signed byte (AVR & ARM) --> It's clear |
char is unsigned (!) for the Due !! int is 16 bit signed on AVR double is not double on AVR, its just an alias for float on AVR Arduinos, for the Zero I don't know. |
Well, from https://www.arduino.cc/en/Reference/Char: "The char datatype is a signed type, meaning that it encodes numbers from -128 to 127. For an unsigned, one-byte (8 bit) data type, use the byte data type". It not distinct AVR from ARM. Who is right, then??? And as I said at first message: in https://www.arduino.cc/en/Reference/Word is written: "A word stores a 16-bit unsigned number, from 0 to 65535. Same as an unsigned int." But in https://www.arduino.cc/en/Reference/UnsignedInt is written "The Due stores a 4 byte (32-bit) value, ranging from 0 to 4,294,967,295 (2^32 - 1)." So I infer Due (and Zero?) also store 4 bytes in the word type. Who is right, then?? |
try it: _targeting the DUE char is definitely unsigned!_ from systematic reasons, a word is the amount of data that a machine can process at one time and equals the register size....: A word is the amount of data that a machine can process at one time. This fits into the document analogy that includes characters (usually eight bits) and pages (many words, often 4 or 8KB worth) as other measurements of data. A word is an integer number of bytes for example, one, two, four, or eight. When someone talks about the "n-bits" of a machine, they are generally talking about the machine's word size. For example, when people say the Pentium is a 32-bit chip, they are referring to its word size, which is 32 bits, or four bytes. The size of a processor's general-purpose registers (GPR's) is equal to its word size. The widths of the components in a given architecture for example, the memory bus are usually at least as wide as the word size. Typically, at least in the architectures that Linux supports, the memory address space is equal to the word size[2]. Consequently, the size of a pointer is equal to the word size. Additionally, the size of the C type long is equal to the word size, whereas the size of the int type is sometimes less than that of the word size. For example, the Alpha has a 64-bit word size. Consequently, registers, pointers, and the long type are 64 bits in length. The int type, however, is 32 bits long. The Alpha can access and manipulate 64 bits, one word at a time. So on 8-bit AVR, a "word" is supposed to have 8bits=1 byte, and 32-bit-ARM core has a 32-bit (4-byte) "word". |
Well, tha't why I've opened this issue...to clarify the use of the right words in defining the data types on both architectures |
ok, what _IS_ is easy to find out:
on Mega: sizeof(char) == 1 on Due: sizeof(char) == 1 |
but that does not always apply to C standards, nevertheless they also are ambiguous!
|
Well, if you don't mind, i'll close this issue and I'll reopen a new one with a more concise text as this one has become a little hard to follow |
In https://www.arduino.cc/en/Reference/Word is written: "A word stores a 16-bit unsigned number, from 0 to 65535. Same as an unsigned int. " But in https://www.arduino.cc/en/Reference/UnsignedInt is written "The Due stores a 4 byte (32-bit) value, ranging from 0 to 4,294,967,295 (2^32 - 1)." So...
*Does the Due also store 4 bytes in the word type?
*If so...maybe it should be noted that then, in Due the word type and the unsigned long type are the same and also the int type and the long type.
*What about the Zero? It's the same than the Due?
In https://www.arduino.cc/en/Reference/Double only mentions Due has 8-byte precision. Zero too?
The text was updated successfully, but these errors were encountered: