CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #5
    Join Date
    Feb 2017
    Posts
    674

    Re: Review, divide two integers

    Quote Originally Posted by TheJollyRoger View Post
    Thanks. Now I've fixed that issue.
    Note that there's a distinction between integer types and floating point types in C++. Make sure you fully understand this distinction and the implications.

    Regarding integer division. This,
    Code:
    int rest = x / y; // / gives quotient
    will give you the quotient (not the rest) of x divided by y. This,
    Code:
    int rest = x % y; // % gives remainder
    will give you the remainder (the rest) of x divided by y. if it is 0 then x is evenly divisible by y. That's what you should use in isFactor().
    Last edited by wolle; August 31st, 2017 at 12:04 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured