0

Which file can I find the implementation of unsigned long long division (ulonglong divided by ulong) in? (MS VC++ 2010)

user410600
  • 127
  • 1
  • 7

2 Answers2

0
  • Write a simple routine which does the division:

#include "stdafx.h"

int main()
{
    unsigned long long a=123;
    unsigned long long b=10;
    a=a/b;
}
  • Set a breakpoint in the line which says a=a/b;
  • Start your program in debug configuration, when it stops at the breakpoint hit F11 to step into.

Now there are two possibilities:

  1. The debugger opens some assembler file called "ulldiv.asm". This means you have the CRT sources installed and now you read the implementation.

  2. Nothing happens or a message pops up. This means that you don't have the sources to the CRT or you're compiling for 64 bit in which case division isn't handled by a library routine.

Nordic Mainframe
  • 28,058
  • 10
  • 66
  • 83
0

Assuming you used the default installation directory, it should be somewhere around:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\crt\src\intel\ulldiv.asm

If you're using a 32-bit edition of Windows, that'll (probably) be C:\program files instead of c:\program files (x86). Despite the comments, this code is really for an unsigned long long divide, not just unsigned long divide (i.e., it takes 64-bit operands, not 32-bit).

I'd have to check to be sure, but I believe the compiler can/will generate inline code for the division when intrinsics are enabled. Of course, a 64-bit compiler will generate inline code in any case.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111