Connecting Tech Pros Worldwide Help | Site Map

Problems with mod

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 19th, 2005, 07:11 PM
John Smith
Guest
 
Posts: n/a
Default Problems with mod

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



  #2  
Old July 19th, 2005, 07:11 PM
Mike Wahler
Guest
 
Posts: n/a
Default Re: Problems with mod

"John Smith" <someone@microsoft.com> wrote in message
news:R2Gib.754488$YN5.707251@sccrnsc01...[color=blue]
> 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.[/color]

Show us the code, and we'll try to sort it out.
[color=blue]
>As a test I
> typed the following in the Visual Studio quick watch window: "3400 %[/color]
1515".[color=blue]
> This evaluated to 0x000009d6 (2518 in decimal). 2518 being larger then
> 1515, this is not only an inaccurate, but invalid result![/color]

To me, "inaccurate" and "invalid" mean the same thing in
this case. :-)
[color=blue]
>Has anyone else
> seen a simalar problem?[/color]

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.
[color=blue]
> Is there a patch or something I need to download?[/color]

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


  #3  
Old July 19th, 2005, 07:11 PM
lilburne
Guest
 
Posts: n/a
Default Re: Problems with mod

John Smith wrote:
[color=blue]
> 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?
>[/color]

0x3400 % 0x1515 = 0x09d6

  #4  
Old July 19th, 2005, 07:12 PM
Jonathan Mcdougall
Guest
 
Posts: n/a
Default Re: Problems with mod

> I'm using Microsoft Visual C++ 6.0. I've been having trouble with my[color=blue]
> % 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![/color]

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

0x3400 % 0x1515 = 0x9d6
[color=blue]
>Has anyone else seen a simalar problem?[/color]

What problem?
[color=blue]
> Is there a patch or
> something I need to download?[/color]

Coffee :)


Jonathan


  #5  
Old July 19th, 2005, 07:12 PM
Ron Natalie
Guest
 
Posts: n/a
Default Re: Problems with mod


"Jonathan Mcdougall" <jonathanmcdougall@DELyahoo.ca> wrote in message news:jUJib.42878$Mv6.976957@wagner.videotron.net.. .[color=blue][color=green]
> > 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![/color]
>
> If 3400 and 1515 are hex numbers, the result is correct, that is
>
> 0x3400 % 0x1515 = 0x9d6
>[/color]
Yep, take your watch window out of Hexademcimal mode (right click on it).


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.