Problems with mod

Discussion in 'C++' started by John Smith, Oct 13, 2003.

  1. John Smith

    John Smith Guest

    I'm using Microsoft Visual C++ 6.0. I've been having trouble with my %
    operator in my code; it doesn't seem to be working correctly. As a test I
    typed the following in the Visual Studio quick watch window: "3400 % 1515".
    This evaluated to 0x000009d6 (2518 in decimal). 2518 being larger then
    1515, this is not only an inaccurate, but invalid result! Has anyone else
    seen a simalar problem? Is there a patch or something I need to download?

    Thanks IA
     
    John Smith, Oct 13, 2003
    #1
    1. Advertising

  2. John Smith

    lilburne Guest

    John Smith wrote:

    > I'm using Microsoft Visual C++ 6.0. I've been having trouble with my %
    > operator in my code; it doesn't seem to be working correctly. As a test I
    > typed the following in the Visual Studio quick watch window: "3400 % 1515".
    > This evaluated to 0x000009d6 (2518 in decimal). 2518 being larger then
    > 1515, this is not only an inaccurate, but invalid result! Has anyone else
    > seen a simalar problem? Is there a patch or something I need to download?
    >


    0x3400 % 0x1515 = 0x09d6
     
    lilburne, Oct 14, 2003
    #2
    1. Advertising

  3. John Smith

    Mike Wahler Guest

    "John Smith" <> wrote in message
    news:R2Gib.754488$YN5.707251@sccrnsc01...
    > I'm using Microsoft Visual C++ 6.0. I've been having trouble with my %
    > operator in my code; it doesn't seem to be working correctly.


    Show us the code, and we'll try to sort it out.

    >As a test I
    > typed the following in the Visual Studio quick watch window: "3400 %

    1515".
    > This evaluated to 0x000009d6 (2518 in decimal). 2518 being larger then
    > 1515, this is not only an inaccurate, but invalid result!


    To me, "inaccurate" and "invalid" mean the same thing in
    this case. :)

    >Has anyone else
    > seen a simalar problem?


    Not I. I wrote and compiled the following with MSVC++ v6.0 SP5 :

    #include <iostream>

    int main()
    {
    std::cout << 3400 % 1515 << '\n';
    return 0;
    }

    It gives the output:

    370


    When I pasted the expression '3400 % 1515' (without the
    quotes) into a quick watch window and clicked the "Recalculate"
    button, I got a result of 370. Perhaps you're having trouble
    using your debugger, which is of course not topical here.

    > Is there a patch or something I need to download?


    I believe the latest (and last) patch for MSVC++ v6.0
    is "Service Pack 5", but I doubt this patch (or lack
    of it) has anything to do with your problem (of course
    I could be wrong, Microsoft has been known to do some
    strange things. :)).

    -Mike
     
    Mike Wahler, Oct 14, 2003
    #3
  4. > I'm using Microsoft Visual C++ 6.0. I've been having trouble with my
    > % operator in my code; it doesn't seem to be working correctly. As
    > a test I typed the following in the Visual Studio quick watch window:
    > "3400 % 1515". This evaluated to 0x000009d6 (2518 in decimal). 2518
    > being larger then 1515, this is not only an inaccurate, but invalid
    > result!


    If 3400 and 1515 are hex numbers, the result is correct, that is

    0x3400 % 0x1515 = 0x9d6

    >Has anyone else seen a simalar problem?


    What problem?

    > Is there a patch or
    > something I need to download?


    Coffee :)


    Jonathan
     
    Jonathan Mcdougall, Oct 14, 2003
    #4
  5. John Smith

    Ron Natalie Guest

    "Jonathan Mcdougall" <> wrote in message news:jUJib.42878$...
    > > I'm using Microsoft Visual C++ 6.0. I've been having trouble with my
    > > % operator in my code; it doesn't seem to be working correctly. As
    > > a test I typed the following in the Visual Studio quick watch window:
    > > "3400 % 1515". This evaluated to 0x000009d6 (2518 in decimal). 2518
    > > being larger then 1515, this is not only an inaccurate, but invalid
    > > result!

    >
    > If 3400 and 1515 are hex numbers, the result is correct, that is
    >
    > 0x3400 % 0x1515 = 0x9d6
    >

    Yep, take your watch window out of Hexademcimal mode (right click on it).
     
    Ron Natalie, Oct 14, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. praveen

    MOD function synthesis

    praveen, Sep 23, 2003, in forum: VHDL
    Replies:
    1
    Views:
    846
    Allan Herriman
    Sep 24, 2003
  2. Kwaj

    Mod (%) Function in VHDL

    Kwaj, Jan 14, 2004, in forum: VHDL
    Replies:
    7
    Views:
    44,365
    jacky Renaux
    Jan 20, 2004
  3. Hari Sekhon
    Replies:
    0
    Views:
    514
    Hari Sekhon
    Jun 20, 2006
  4. ryles
    Replies:
    3
    Views:
    537
    Piet van Oostrum
    Jul 26, 2009
  5. T. Onoma
    Replies:
    9
    Views:
    358
    Dave Thomas
    Dec 15, 2003
Loading...

Share This Page