Teen Programmers Unite  
 

 

Return to forum top

Double type

Posted by JACKsprat [send private reply] at January 12, 2002, 03:15:40 AM

I know it saves real numbers. I am having a hard time with remembering this one. When I have an expression, do i do the problem as if it where and int or do then promote the value? Or do i do the promotion right off the bat?
example.
double x;
x= 10 / 5 ;
its 2 but when its assigned to x its changes to 2.0? Is this right?

Posted by Psion [send private reply] at January 12, 2002, 05:41:55 AM

That is correct. If you had x = 1/2, the result of this integer division would be 0, and then be cast to the double value 0.0.

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.