How should i decide which integer type to use?
chrispitt
-2
Light Poster
Recommended Answers
Jump to PostHow should i decide which integer type to use?
When in doubt, use
int
. Ifint
doesn't have the range you need or if you have special needs (eg. heavily restricted memory) that justify a smaller integer type, use something different. Over time you'll get a feel for …
Jump to PostIf you need to store large values (above 32,767 or below -32,767), use long.
If space is very important (i.e. if there are large arrays or many structures), use short.
Otherwise, use int.
Jump to PostValid point. Looking again at the page I'd linked to, I see I was clearly mistaken. I think I was jumping to a conclusion that the mridul.ahuja was talking about Turbo C, and went off half-cocked as a result. Also, it is so common to see 32-bit
int
s these days …
All 11 Replies
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
mridul.ahuja
4
Coding Enthusiast
deceptikon
commented:
Kudos for getting the guaranteed range of int correct.
+12
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
mridul.ahuja
4
Coding Enthusiast
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.