Newsgroup: comp.lang.java.programmer


Date: Wed, 12 Apr 2006 16:38:49 +0300
From: Diomidis Spinellis <dds@aueb.gr>
Organization: Athens University of Economics and Business
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0
MIME-Version: 1.0
Newsgroups: comp.lang.java.programmer
Subject: Re: when is it necessary to use suffix of literals?
References: <1144844837.328276.120720@i39g2000cwa.googlegroups.com> <e1isne$evp$1@volcano1.grnet.gr> <1144847969.437010.104430@v46g2000cwv.googlegroups.com>
In-Reply-To: <1144847969.437010.104430@v46g2000cwv.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
xian_hong2046@hotmail.com wrote:
> I see, so does it mean the trailing suffixes are only used when the
> literals are not assigned to any variable?  Because if the literals are
> assigned to some variables, the types of the variables (long, double)
> should tell the compiler how much memory should be allocated to the
> values.  Is this right?

Assignment to a variable is not relevant.  For example, the following 
code will still print 0.

	int i = 0x80000000 * 0x100;
	System.out.println(i);

What the trailing suffixes do is to FORCE the EVALUATION of an 
expression to use the specific type.

-- 
Diomidis Spinellis
Code Quality: The Open Source Perspective (Addison-Wesley 2006)
http://www.spinellis.gr/codequality?cljp



Newsgroup comp.lang.java.programmer contents
Newsgroup list
Diomidis Spinellis home page

Creative Commons License Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.