How to select the integers after the decimal?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Wright
    New Member
    • Feb 2011
    • 1

    How to select the integers after the decimal?

    So, I'm pretty new to C# but heres my problem.
    After multiplying a number by a percentage I am converting the double to an int and assigning that to a variable. However, I also need to get the the integers after the decimal and assign them to another variable.

    What is the syntax that allows me to select the integers after the decimal?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    There's no such thing as an integer after a decimal since an integer by definition is a number without a fractional part.

    However, that is just semantics and what you mean is that you just want the "fractional " part of the the percentage. I'm assuming you multiplied the percentage by 100 otherwise you wouldn't have an integer portion of the percentage.

    Just take the double and subtract the integer.

    Comment

    Working...