Solved

# About the LONG data type

Posted on 1998-11-17
231 Views
Why the following is illegal
long number = 234567890*10;
while the following is legal??
long number = 2345678900;
0
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
• 2

LVL 86

Accepted Solution

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

ID: 1178052
tks a lot!!!
0

LVL 86

Expert Comment

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

## Featured Post

Question has a verified solution.

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

### Suggested Solutions

Writing a parser for java language 4 100
C++ Language error 28 309
Embarcadero C++ Builder XE2 TDateTime 8 90
Best book to learn C++ 4 96
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
###### Suggested Courses
Course of the Month7 days, 14 hours left to enroll