473,322 Members | 1,408 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,322 software developers and data experts.

Problem with the suffix of a constant

hello, i've got this problem , as example :

Expand|Select|Wrap|Line Numbers
  1.  long number = 2000000000 
my manual says that you must place a suffix after 2000000000 :
Expand|Select|Wrap|Line Numbers
  1.  long number = 2000000000L
.

suffix L means int must be long.

but why place L , cause 2000000000 isn't integer (not enough capacity), 2000000000 is long!!!!!! why then place L????

im dutch, please explain easy

thanks
Aug 28 '07 #1
3 1677
RRick
463 Expert 256MB
In your example, either declaration will work fine. The compiler knows that the big value is long, not because of the size of the value, but because "number" is "long". The compiler will convert any numeric constant to the format declared by the variable. For example:
Expand|Select|Wrap|Line Numbers
  1. char c = 1;
  2. int i = 1;
  3. double d = 1;
In each case the number 1 will be converted to the format specified by the format of the variable.
Aug 28 '07 #2
JosAH
11,448 Expert 8TB
im dutch, please explain easy
No you're not; you much more ignorant than the Dutch will ever be. Watch your language.

Jos
Aug 28 '07 #3
JosAH
11,448 Expert 8TB
In your example, either declaration will work fine.
No it won't. That's why those suffixes are there. The compiler is a bit stupid
when it comes to literals, i.e. the literal number was scanned/parsed in a previous
phase where nothing was known yet about the type of the target. Consider it a
remnant from the old days where 64KB was considered a lot of memory.

kind regards,

Jos
Aug 28 '07 #4

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

Similar topics

1
by: Stevo | last post by:
I'm trying to parse the output of ipconfig /all to retrieve the first MAC address that is not part of a VM adapter and the second byte should not be 50. A sample return is as follows: I'm able to...
7
by: skg | last post by:
Hi, I'm writing a c++ code, where in i'm passing a double value to a function. What i'm sending is a double value in scientific mode say set_value (1234e5.6) G++ compiler cribs about...
24
by: diego.arias.vel | last post by:
Hi all I have certain problem when I'm doing this: void copy(char *filename) { char *log_file; log_file=filename; strcat(log_file,"-log.txt");
9
by: Hamish M | last post by:
Hi I am interested in opinions on this topic. I have heard that a suffix is not a good solution and type casts are much better for example. ...
18
by: mati | last post by:
Hi The following code works: #include <vector> class C { private: static const int m_static = 2; public: void f(const std::vector<int>& v)
7
by: plumb and tree | last post by:
I've been trying for days to build 64 bit python with Solaris 10 + Sun Studio 12. Can anyone helpl please. This is how I tried to do build: # ./configure --prefix=/opt/python2.4...
5
by: MarkStorer | last post by:
Hi All This is probably an easy fix for you experts out there, but the solution is beyond a newbie like me. I have a table containing several customer fields - with the key field 'Customer' ...
41
by: dspfun | last post by:
Hi! Are suffixes allowed on expressions? For example, is the following allowed: #define SECONDS_PER_YEAR (60 * 60 * 365) UL I found this in a C test at...
0
by: okonita | last post by:
Hi all, I am having a DB2 connectivity problem that I hope someone can help me resolve. I need this to test Replication and such other things. What am I doing wrong here? Any help that I can get...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.