Problems with mod

J

John Smith

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
 
L

lilburne

John said:
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
 
M

Mike Wahler

John Smith said:
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
 
J

Jonathan Mcdougall

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
 
R

Ron Natalie

Jonathan Mcdougall said:
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).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top