473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Different Data types

i was actually getting a doubt that when to use long and when to use long long and what is the difference between them? and sometimes we also use long int ....couls u please clarify which data type are to be used when and where and at what situations?
May 5 '14 #1

✓ answered by donbock

There are differing opinions, but I suggest that the simplest rule to follow for integral types in general-purpose software is:
  1. Use int if the value fits in 16 bits;
  2. If that's too small, use long if the value fits in 32 bits;
  3. If that's too small, use long long if the value fits in 64 bits;
  4. If that's too small ... Then you're out of luck.
There are many more integral types to choose from, but you can get by without them unless you have a specialized application. Writing software for an embedded system is one example of a specialized application that might demand more integral types.

2 1844
donbock
2,426 Expert 2GB
There are differing opinions, but I suggest that the simplest rule to follow for integral types in general-purpose software is:
  1. Use int if the value fits in 16 bits;
  2. If that's too small, use long if the value fits in 32 bits;
  3. If that's too small, use long long if the value fits in 64 bits;
  4. If that's too small ... Then you're out of luck.
There are many more integral types to choose from, but you can get by without them unless you have a specialized application. Writing software for an embedded system is one example of a specialized application that might demand more integral types.
May 5 '14 #2
donbock
2,426 Expert 2GB
By the way, never use char for integer numbers -- only use it for characters. If you want a small type for numbers then use signed char or unsigned char.
May 5 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: J. Campbell | last post by:
I have a feeling that I'm doing things all ass-backwards (again ;-), and would like some advice. What I want to do is: put some data to memory and then access that memory space as an array of...
2
by: Mitch Mooney | last post by:
Subject line says it all. For example: //base class class foo{ public: foo(); ~foo(); virtual ??? GetValue()=0; };
7
by: smith4894 | last post by:
Hello, I have a question regarding storage locations for different data types. For example, dynamically created objects (using "new") are created on the heap. local objects ( foo() {int x;} )...
4
by: troloo | last post by:
Hello, I hope you can help me :)) The story goes as follows: I have a class with different methods and member variables. I store pointers to objects of this class inside a vector. Now, I would like...
1
by: John Smith | last post by:
How do I use two different data types with a conditional operator ? I want to cout either a character or an integer depending on a certain condition. cout << ((IsThisTrue? char:integer) The...
2
by: Schnogge | last post by:
Hi! it is possible to generate an multiple-dimensional array with different data types? Or is it possible to combine a one-dimensional array with an other which has an other data type? How...
6
by: RaulAbHK | last post by:
Dear all, I guess this is a basic question with an easy answer but I am a beginner and I would much apreciate your feedbacks. Let's say I have a library with some functionality to perform some...
4
by: WuJianWei | last post by:
Is there a way(function) to distingusih between different data types? if u can, provide me with the code... thank u...
4
by: herath | last post by:
Is there a way to join 2 tables where the 2 fields on which the tables joined are of different data types(char and varchar)?I tried with CONVERT but is does not give the desired output. My...
3
by: charli | last post by:
SQL: SELECT COUNT(month) as c FROM pool WHERE = "GP06NHL" AND = "43.38" AND = "NORMAL UNLEADED" AND = #01/04/2009# Gives 'Data Type Mismatch' because the 43.38 is delimited as a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.