Go Down

Topic: 'uint8_t' instead 'Int' (Read 2 times) previous topic - next topic

Pedro Ferrer

Good afternoon

I would like to optimize Arduino RAM utilization.
I use 'Int' variables instead 'Byte' because it seems to me more practical to use in comparisons, conversions...

I would like to know if I'm improving something using 'uint8_t' instead 'Int'... because some variables that I'm using are in 0-255 range.

Please let me know
Thanks on advance
Best regards
Pedro Ferrer

AWOL

Quote
I would like to know if I'm improving something using 'uint8_t' instead 'Int'..

Yes, quicker and consuming less program and RAM memory.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

PaulS

Quote
I use 'Int' variables instead 'Byte' because it seems to me more practical to use in comparisons, conversions.

How? The type of a variable matters little when constructing an if statement, for instance. When converting from one type to another to another, the types matter, but converting from byte to float is exactly the same as converting from int to float.

This statement needs some additional explanation, I think.

Pedro Ferrer

Hello

Thanks by your prompt answers.

How much I'll improving RAM on each 'uint8_t' instead 'Int' ?

(...)

PaulS
Eg: using ITOA... Integer to Ascii... is some of the reason that's why I'm using 'Int' instead 'Byte'

Thanks once again
Best regards
Pedro Ferrer

AWOL

The natural word size of the AVR's RAM datapaths is 8 bits, so a "byte" type (8 bits) will be fetched into a CPU register more quickly than an "int" type (16 bits), and an "int" will require more program memory to hold the extra instructions to fetch and manipulate it.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up