Solved

About the LONG data type

Posted on 1998-11-17
3
234 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

728 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