|
-
May 30th, 2001, 05:30 PM
#1
Thread Starter
Hyperactive Member
floats 'n integers
Code:
int gains;
for(i=1;i<=j;i++){
cout<<i<< " ";
gains = (amountY*interestR)/100.0f;
amountY = amountY + gains;
cout <<amountY << endl;
}
The problem here is that amountY and interestR have to be integers, becasue they were formmated as a character and I had to format them to a integer. But gains has to be a float. Is there a way to convert things to work correctly, that is mixing a float and integer? Can I convert char to float? Thanks
Matt 
-
May 30th, 2001, 05:50 PM
#2
Monday Morning Lunatic
I can't see what you're asking here.
Code:
char x = 56;
float y = x;
y = 3.43f;
x = y; // Should give a compiler warning about loss of accuracy
Are you trying to interpret a string as a float, rather than as an integer like atoi?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 31st, 2001, 02:19 PM
#3
Thread Starter
Hyperactive Member
basically yes, can I do that, and what function can I use?
Matt 
-
Jun 1st, 2001, 02:49 PM
#4
Monday Morning Lunatic
atof
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 1st, 2001, 02:50 PM
#5
Thread Starter
Hyperactive Member
perfect
Matt 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|