Solved

About the LONG data type

Posted on 1998-11-17
3
228 Views
Last Modified: 2010-04-01
Why the following is illegal
long number = 234567890*10;
while the following is legal??
long number = 2345678900;
0
Comment
Question by:helloyip
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 1178051
The highest value for a signed long is 2^32 ==  2147483648;
By assigning 'number = 2345678900', (which is the same as 'number = 0x8BD03834'), 'number' has the actual value '-1949288396', whilst multiplying '234567890*10' would cause a signed long overflow.
0
 

Author Comment

by:helloyip
ID: 1178052
tks a lot!!!
0
 
LVL 86

Expert Comment

by:jkr
ID: 1178053
Ooops: BTW - what compiler are you using? It should at least issue a warning...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question