finding a decimal

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amoz
    New Member
    • Jun 2007
    • 4

    finding a decimal

    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!
  • ilikepython
    Recognized Expert Contributor
    • Feb 2007
    • 844

    #2
    Originally posted by amoz
    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:
    [code=cpp]
    float num = 6.2357;
    float decimal = num - (int)num;
    cout << decimal << endl; // outputs "0.2357"
    [/code]

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Please do not double post.

      Comment

      Working...