how do you make an integer accept a decimal value?
I know i knew this, but now...and it's not in the faq
somebody please help
how do you make an integer accept a decimal value?
I know i knew this, but now...and it's not in the faq
somebody please help
Use a float, not an int?
Demonographic rhinology is not the only possible outcome, but why take the chance
use a doublehow do you make an integer accept a decimal value?
eg;
double n = 6.0
U R right, pretty simple, my friend
cj
"Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
-Bruce Lee
u could cast it.
int variable;
int final;
final = double(variable);
errr... no. final is an int and will only ever hold an int value. The use of the implied cast is also incorrect, you meant this:Originally posted by Ride -or- Die
u could cast it.
int variable;
int final;
final = double(variable);
>final = (double)variable;
... but it wouldn't store the digits to the right of the decimal point, if there were any. Of course, there can't be any though, as variable is an int as well.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
wow....
thanks for all the alternatives, but i think i'll stick with "float".
Sorry to trouble you with such a simple question.
I don't see anything wrong with double(variable).Originally posted by Hammer
>>final = double(variable);
The use of the implied cast is also incorrect, you meant this:
final = (double)variable;
It is C++-style casts.
Nevertheless, the cast is useless.
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
I don't think we can cast with: double(variable).
it's just like:
isn't it?Code:int x=5; double y=9; x=y;
>>It is C++-style casts.
Oops, you're right, I didn't spot that
>>Nevertheless, the cast is useless.
That was my main point too.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]