Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

About the LONG data type

Posted on 1998-11-17
3
Medium Priority
?
241 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 300 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

610 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