Talk About Network

Google





Programming > C - C++ Learning > Include decimal...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 4195 of 4400
Post > Topic >>

Include decimal point in floating point values?

by Pat <pkelecy@[EMAIL PROTECTED] > Jul 7, 2008 at 02:53 PM

I know this is pretty basic, but is there any difference between:

	double x = 3.0;
	double y = x/4.0;

and

	double x = 3;
	double y = x/4;
?

In other words, if I don't include a decimal point when using a whole 
number in a type double expression, as in the second case, does the 
compiler assume it's an integer and do a type cast when  evaluating it? 
  If so, does that mean it's more efficient to always include the 
decimal point in this situation?

Thanks for the explanation.  -Pat
 




 6 Posts in Topic:
Include decimal point in floating point values?
Pat <pkelecy@[EMAIL PR  2008-07-07 14:53:57 
Re: Include decimal point in floating point values?
Richard Heathfield <rj  2008-07-07 22:18:09 
Re: Include decimal point in floating point values?
Pat <pkelecy@[EMAIL PR  2008-07-07 18:54:59 
Re: Include decimal point in floating point values?
Keith Thompson <kst-u@  2008-07-08 09:50:05 
Re: Include decimal point in floating point values?
Scott Seidman <namdies  2008-07-08 19:35:17 
Re: Include decimal point in floating point values?
Keith Thompson <kst-u@  2008-07-08 15:40:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Fri Jan 9 5:29:32 PST 2009.