By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,064 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,064 IT Pros & Developers. It's quick & easy.

finding a decimal

P: 4
I need to know how to find a decimal in a number. In VB, it's possible to convert using str$ and finding the decimal in the string version...how is this fone in c++
thanks for help!
Jun 15 '07 #1
Share this Question
Share on Google+
2 Replies


ilikepython
Expert 100+
P: 844
I need to know how to find a decimal in a number. In VB, it's possible to convert using str$ and finding the decimal in the string version...how is this fone in c++
thanks for help!
For example, take 6.2357. You went to get 0.2357, correct?
This will do it:
Expand|Select|Wrap|Line Numbers
  1. float num = 6.2357;
  2. float decimal = num - (int)num;
  3. cout << decimal << endl;      // outputs "0.2357"
  4.  
Jun 15 '07 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
Please do not double post.
Jun 15 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.