The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: nixeagle on May 09, 2012, 02:31:22 AM

Title: How do you print a floating point number?
Post by: nixeagle on May 09, 2012, 02:31:22 AM
Alright, working on showing standard deviations and mean clocks for the timing program I'm working on in http://www.masm32.com/board/index.php?topic=18787.0 . My problem is printing the floating point value from the floating point stack to standard out. What do you guys do?

Title: Re: How do you print a floating point number?
Post by: hutch-- on May 09, 2012, 02:38:54 AM
Convert it to string then point it where you like.
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 09, 2012, 02:52:55 AM
Quote from: hutch-- on May 09, 2012, 02:38:54 AM
Convert it to string then point it where you like.
:lol, I was kinda hoping someone would have already done the "convert it to a string" part. That is the actual work! :wink.
Title: Re: How do you print a floating point number?
Post by: P1 on May 09, 2012, 04:11:52 AM
Quote from: nixeagle on May 09, 2012, 02:52:55 AM
Quote from: hutch-- on May 09, 2012, 02:38:54 AM
Convert it to string then point it where you like.
:lol, I was kinda hoping someone would have already done the "convert it to a string" part. That is the actual work! :wink.
I would use the "Search" Box.  This is not that original of a problem.

Regards, P1  :8)
Title: Re: How do you print a floating point number?
Post by: dedndave on May 09, 2012, 04:17:27 AM
there are some past threads regarding this function
as i recall, Jochen had a nice fast routine (jj2007)
so - you can use the Advanced Search options - and narrow the search to posts by jj2007

also...
Ray's FPU library has a routine for this
http://www.ray.masmcode.com/
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 09, 2012, 04:20:46 AM
Alright, I'll dig up jj2007's thing. I'd like to keep this as simple as possible and not include a ton of extra libraries if I can avoid it. This was meant to be small and simple ::). I'm almost done with the work of tracking errors through all the calculations so the final result has the correct error associated with it. That'll make it so we can say this result is 20 ticks +/- 2 ticks (or this result is 20 ticks +/- 10%), whichever format you guys end up liking more :)
Title: jj2007, your float$ macro was deleted by admin, happen to have a copy?
Post by: nixeagle on May 09, 2012, 04:24:53 AM
:( facepalm :(

Quote
[attachment deleted by admin]

for jj2007's float$ macro listed in http://www.masm32.com/board/index.php?topic=9756.0

jj2007, you happen to still have a copy? :bg
Title: Re: How do you print a floating point number?
Post by: dedndave on May 09, 2012, 04:29:34 AM
oh - i forgot to mention...
the crt has printf, as well as other similar functions, that can do it
no muss no fuss   :P

well - you have to know a little about formatting printf
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 09, 2012, 04:34:01 AM
Quote from: dedndave on May 09, 2012, 04:29:34 AM
oh - i forgot to mention...
the crt has printf, as well as other similar functions, that can do it
no muss no fuss   :P

well - you have to know a little about formatting printf

Whichever works. I don't know what you mean by crt though. I honestly just want to display this and move on ::) as I'm almost down to a "real" version of this :bg. For example, my current output is:

Running testit_long_baseline.0
Running long_testit_div.: [1276 .. 1276 .. 1280] - Variance: 0 ticks^2 - SDev: 0 ticks.
Running long_testit_cdiv.: [214 .. 257 .. 258] - Variance: 27 ticks^2 - SDev: 5 ticks.
Please subtract testit_long_baseline time from both, then divide by 128.
Running testit_baseline.0
Running testit_div.: [311 .. 311 .. 311] - Variance: 0 ticks^2 - SDev: 0 ticks.
Running testit_cdiv.: [44 .. 45 .. 50] - Variance: 8 ticks^2 - SDev: 3 ticks.
Please subtract testit_baseline time from both, then divide by 32.
Running short_testit_baseline.1
Running short_testit_div.: [39 .. 39 .. 39] - Variance: 1 ticks^2 - SDev: 1 ticks.
Running short_testit_cdiv.: [3 .. 7 .. 8] - Variance: 8 ticks^2 - SDev: 3 ticks.


SDev in the above really should be a floating point number. :wink And really so should the middle number in those ranges.

I'd like to get that spam down to just 6 lines, and possibly even just 2, with the different long, normal, short functions handled automatically. :U
Title: Re: How do you print a floating point number?
Post by: dedndave on May 09, 2012, 04:43:54 AM
crt - msvcrt - microsoft visual C runtime library
if you use \masm32\include\masm32rt.inc, the appropriate files are already included
Title: Re: How do you print a floating point number?
Post by: dedndave on May 09, 2012, 04:44:51 AM
http://msdn.microsoft.com/en-us/library/wc7014hz%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/library/56e442dc%28v=vs.71%29.aspx

it looks like you want one of these "type" specifiers...
e, E, f, g, G
they will display double-precision (qwords) in various ways
http://msdn.microsoft.com/en-us/library/hf4y5e3w%28v=vs.71%29.aspx
i seem to recall that MichaelW gave an example a while back
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 09, 2012, 04:56:58 AM
Quote from: dedndave on May 09, 2012, 04:44:51 AM
http://msdn.microsoft.com/en-us/library/wc7014hz%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/library/56e442dc%28v=vs.71%29.aspx

it looks like you want one of these "type" specifiers...
e, E, f, g, G
they will display double-precision (qwords) in various ways
http://msdn.microsoft.com/en-us/library/hf4y5e3w%28v=vs.71%29.aspx
i seem to recall that MichaelW gave an example a while back

Found it :dance:. http://www.masm32.com/board/index.php?topic=18797.msg159144#msg159144
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 09, 2012, 05:06:31 AM
Quote from: nixeagle on May 09, 2012, 04:56:58 AM
Quote from: dedndave on May 09, 2012, 04:44:51 AM
http://msdn.microsoft.com/en-us/library/wc7014hz%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/library/56e442dc%28v=vs.71%29.aspx

it looks like you want one of these "type" specifiers...
e, E, f, g, G
they will display double-precision (qwords) in various ways
http://msdn.microsoft.com/en-us/library/hf4y5e3w%28v=vs.71%29.aspx
i seem to recall that MichaelW gave an example a while back

Found it :dance:. http://www.masm32.com/board/index.php?topic=18797.msg159144#msg159144

Well that sucks, printf does not output to CygWin's terminal, only to cmd.exe :(. Hopefully jj2007 still has a copy of float$.
Title: Re: How do you print a floating point number?
Post by: hutch-- on May 09, 2012, 05:20:45 AM
Have a look at Ray's version, his FP stuff has been very reliable for years.
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 09, 2012, 05:30:52 AM
Quote from: hutch-- on May 09, 2012, 05:20:45 AM
Have a look at Ray's version, his FP stuff has been very reliable for years.

Alright, I'll do so tomorrow, this is basically the last thing I need to do :). I have all the mathematics and error calculations propagating correctly to account for possible deviations in both the baseline measurements and the test function measurements.

Thanks all :)
Title: Re: How do you print a floating point number?
Post by: jj2007 on May 09, 2012, 06:51:24 AM
Quote from: nixeagle on May 09, 2012, 05:06:31 AMprintf does not output to CygWin's terminal, only to cmd.exe :(. Hopefully jj2007 still has a copy of float$.

nixeagle,

float$ was an early version of Str$(). You can use MB in parallel to your Masm32 installation just by replacing the masm32rt.inc include with MasmBasic's include line. That cares for most other libraries, exotic stuff has to be added by hand. Test the snippet below, the download is at http://www.masm32.com/board/index.php?topic=12460

; include \masm32\include\masm32rt.inc   ; comment out and replace with...
include \masm32\MasmBasic\MasmBasic.inc   ; download (http://www.masm32.com/board/index.php?topic=12460)
.data
My$   dd ?
MyR8   real8 88.8e88
MyR4   real4 4444.4444
MyR10   real10 1234567890.1234567890
MyQw   qword 1234567890123456789

.code
start:
   ; Init    ; should be used instead of code, start: to initialise some special arrays
   Let My$="The number is "+Str$(MyR4)+CrLf$      ; assign to a variable, use whatever StdOut routine you like
   print My$, "(using Masm32 print)", 13, 10
   invoke StdOut, My$         ; that should work everywhere
   deb 4, "The number is", MyR4         ; debug macro, very versatile
   movlps xmm0, MyR8
   fldpi      ; put something on the FPU
   mov eax, 12345
   deb 4, "The numbers are", MyR4, f:xmm0, MyR8, MyR10, ST(0), eax      ; xmm regs need f: to be interpreted as floats
   fadd MyR4
   Print Str$("\nOn the FPU:\t%f\n\n", ST(0))      ; with format string: \t=tab, \n=newline, %i=integer, %f=float
   fstp st
   print Str$("The Real8 is\t%f\n", MyR8)        ; a simple %f uses about 7 digits, but you can use e.g. %9f to print more digits; %Hf is 16 digits
   Print Str$("The Real10 is\t%If", MyR10)
   print Str$("The Qword is\t%i\n", MyQw)
   mov eax, 100
   mov ecx, 10
   movlps xmm1, FP8(1111.1111)
   Print Str$("The result is\t%f", eax/ecx*f:xmm1), " - and here is one more: ", Str$("Pi=%Jf\n", PI)   ; MB Print (uppercase P) allows to concatenate several args
   nop
   Inkey Str$("\n\nYour puter has run %3f hours since the last boot, give it a break!", Timer/3600000)
   Exit        ; uppercase E means it's MasmBasic exitprocess, cleans up arrays etc
end start
Output:
The number is 4444.444
(using Masm32 print)
The number is 4444.444
The number is   MyR4            4444.444

The numbers are
MyR4            4444.444
f:xmm0          8.880000000000000e+89
MyR8            8.880000000000000e+89
MyR10           1234567890.12345679
ST(0)           3.14159265358979324
eax             12345

On the FPU:     4447.586

The Real8 is    8.880000e+89
The Real10 is   1234567890.12345679The Qword is 1234567890123456789
The result is   11111.11 - and here is one more: Pi=3.141592653589793238
Title: Re: How do you print a floating point number?
Post by: dedndave on May 09, 2012, 09:48:53 AM
printf outputs to std_out
fprintf outputs to a file stream
sprintf outputs to a string buffer

you can use it for whatever you like once it's in a buffer - like MessageBox, etc

http://msdn.microsoft.com/en-us/library/ybk95axf%28v=vs.71%29.aspx

_snprintf is a little better - you get to specify the buffer size
http://msdn.microsoft.com/en-us/library/2ts7cx93%28v=vs.80%29.aspx

_snprintf_s - "modern" secure version
http://msdn.microsoft.com/en-us/library/f30dzcf6%28v=vs.80%29.aspx


i might add...
i am not a "C" kind of guy - lol
so, i haven't played with all the different variations of printf

i would probably use Ray's lib   :P
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 09, 2012, 06:14:08 PM
Quote from: dedndave on May 09, 2012, 09:48:53 AM
printf outputs to std_out
fprintf outputs to a file stream
sprintf outputs to a string buffer

you can use it for whatever you like once it's in a buffer - like MessageBox, etc

http://msdn.microsoft.com/en-us/library/ybk95axf%28v=vs.71%29.aspx

_snprintf is a little better - you get to specify the buffer size
http://msdn.microsoft.com/en-us/library/2ts7cx93%28v=vs.80%29.aspx

_snprintf_s - "modern" secure version
http://msdn.microsoft.com/en-us/library/f30dzcf6%28v=vs.80%29.aspx


i might add...
i am not a "C" kind of guy - lol
so, i haven't played with all the different variations of printf

i would probably use Ray's lib   :P

Oh, doh! :red. I'll use likely just use sprintf and then use print.

To jj2007: I really wanted to avoid including extra things that have to be downloaded. This whole thing is meant to be a lightweight timing tool for microbenchmarking. If I can get away with the basics that everyone has just by having MASM, that is what I'll do.

If sprintf does not work, I'll just code up a poorman's print_float function that prints the integer part of the number, then multiplies the floating point portion by 1000, shoves that into an integer, take the modulus of it and print that as the last 3 digits after the decimal point. Who needs more than 3 digits on the right side of the decimal point for a timing program that measures in ticks :bdg.

Thanks for the input everyone, I hope to get this finished today, though I need to go through and verify the results are correct with the 4 people who have taken the time to run tests for me :U.
Title: Re: How do you print a floating point number?
Post by: jj2007 on May 09, 2012, 06:50:24 PM
Quote from: nixeagle on May 09, 2012, 06:14:08 PM
I really wanted to avoid including extra things that have to be downloaded. This whole thing is meant to be a lightweight timing tool for microbenchmarking. If I can get away with the basics that everyone has just by having MASM, that is what I'll do.

crt_sprintf will do the job for you, don't worry. Str$() is an overkill in this case.
Title: Re: How do you print a floating point number?
Post by: dedndave on May 09, 2012, 10:35:42 PM
some older versions of sprintf did not handle floats
probably not a problem nowdays - hardly anyone using win95 or whatever

if i wanted  to use the crt, i would probably use _snprintf_s (probably not supported in win95 either - lol)
it doesn't look like the masm32 msvcrt inc/lib has that one
but - you can get it with LoadLibrary/GetProcAddress/FreeLibrary
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 10, 2012, 12:48:45 AM
Quote from: dedndave on May 09, 2012, 10:35:42 PM
some older versions of sprintf did not handle floats
probably not a problem nowdays - hardly anyone using win95 or whatever

if i wanted  to use the crt, i would probably use _snprintf_s (probably not supported in win95 either - lol)
it doesn't look like the masm32 msvcrt inc/lib has that one
but - you can get it with LoadLibrary/GetProcAddress/FreeLibrary

Nice to know, problem is I don't know how to use LoadLibrary and friends on windows :bg. So if I'm unable to get sprintf to work, I'll just hack up a poor-man's float printing function that:

The above algorithm ought to produce output that looks something like:
1234.123

Crude, but it ought to work no matter what platform it is on. :lol
Title: Re: How do you print a floating point number?
Post by: jj2007 on May 10, 2012, 02:30:23 AM
I've hacked together something.

include \masm32\include\masm32rt.inc

float$ MACRO arg8
  ifndef sprBuffer
.data?
sprBuffer db 40 dup(?)
.data
sprFormat db "%f", 0
.code
  endif
  invoke crt_sprintf, offset sprBuffer, offset sprFormat, arg8
  EXITM <offset sprBuffer>
ENDM

.code
start:
MsgBox 0, float$(FP8(1234.5678)), "Wow, a number:", MB_OK
exit
end start


Attention JWasm doesn't like usiing the macro on the same line as a label, e.g.:
start:   MsgBox 0, float$(FP8(1234.5678)), "Wow, a number:", MB_OK
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 10, 2012, 02:45:00 AM
Quote from: jj2007 on May 10, 2012, 02:30:23 AM
I've hacked together something.

Very nice :bg. While you were off hacking, I was doing the same. Follows is my poor-man's print_float


;; assume pointer to float is in eax
;; float is REAL8
print_float PROC
    push ebx
    push ecx
    push edx
    fld REAL8 PTR [eax]            ; Load, store as integer, and print
    fist DWORD PTR [esp+4]        ; the integer portion of the number.
    mov eax, [esp+4]
    print ustr$(eax)

    print "."                      ; Print decimal point marker.

    mov ebx, 3
  l:
    ;;; now prepare to print first 3 digits after the decimal point.
    mov ecx, 10
    mov [esp+4], ecx
   
    fimul DWORD PTR [esp+4]
    fist DWORD PTR [esp+4]
    mov eax, [esp+4]
    mov ecx, 10
    xor edx, edx
    div ecx
    ;; we want remainder, which is in edx.
    print ustr$(edx)

    dec ebx
    jns l
    fistp DWORD PTR [esp+4]
    pop edx
    pop ecx
    pop ebx
    ret
print_float ENDP
Title: Re: How do you print a floating point number?
Post by: raymond on May 10, 2012, 04:28:02 PM
Quote    fld REAL8 PTR [eax]            ; Load, store as integer, and print
    fist DWORD PTR [esp+4]        ; the integer portion of the number.

Whenever you assume something, you risk being wrong half the time.

Since I haven't seen all your source code, I may be wrong myself in assuming that you are not aware of all the intricacies of using FPU instructions. In case I am right, please read at least the first paragraph of the following:
http://www.ray.masmcode.com/tutorial/fpuchap5.htm#fist
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 10, 2012, 07:33:10 PM
Quote from: raymond on May 10, 2012, 04:28:02 PM
Quote    fld REAL8 PTR [eax]            ; Load, store as integer, and print
    fist DWORD PTR [esp+4]        ; the integer portion of the number.

Whenever you assume something, you risk being wrong half the time.

Since I haven't seen all your source code, I may be wrong myself in assuming that you are not aware of all the intricacies of using FPU instructions. In case I am right, please read at least the first paragraph of the following:
http://www.ray.masmcode.com/tutorial/fpuchap5.htm#fist


The stack will not overflow if that is what you are getting at. I know the state of the floating point stack at the time this function is called. If you are talking about something else, I'd love to know :bg.
Title: Re: How do you print a floating point number?
Post by: raymond on May 10, 2012, 08:26:50 PM
Here'e the quote I wanted you to read from the description of the fist instruction:
QuoteThis instruction rounds the value of the TOP data register ST(0) to the nearest integer according to the rounding mode of the RC field in the Control Word,

When you open a program, the FPU contol word defaults at a rounding mode of "Round to nearest, or to even if equidistant (this is the initialized state)"

Therefore, if you are storing a value something like 13.67546 as an integter, it would round it to 14 before storing it, unless you would have changed the RC field of the control word to "truncating". The eventual value displayed would also then be 14.785 according to the code you posted.

If you don't want to start modifying that RC field, there are other precautions you must take to insure getting the correct integer. There are several options.
Title: Re: How do you print a floating point number?
Post by: jj2007 on May 10, 2012, 10:38:12 PM
The FPU is not trivial. On the other hand, a fixed number of decimals routine can be done with a mere 109 bytes, see attachment.

r8a REAL8 12.3456
r8b REAL8 1234.56
r8c REAL8 1234567.89012345678
r8d REAL8 -0.00123456789 ; negative number
r8e REAL8 1.23456
r8f REAL8 -123.456 ; negative number

start:
print floatx$(r8a), 13, 10
print floatx$(r8b), 13, 10
print floatx$(r8c, 100000000), 13, 10
print floatx$(r8d, 10000000), 13, 10
print floatx$(r8e), 13, 10
print floatx$(r8f), 13, 10


Output:
12.346
1234.560
1234567.89012346
-0.0012346
1.235
-123.456


No MasmBasic, no CRT, just plain Masm32 dwtoa :bg
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 10, 2012, 11:21:36 PM
Quote from: raymond on May 10, 2012, 08:26:50 PM
Here'e the quote I wanted you to read from the description of the fist instruction:
QuoteThis instruction rounds the value of the TOP data register ST(0) to the nearest integer according to the rounding mode of the RC field in the Control Word,

When you open a program, the FPU contol word defaults at a rounding mode of "Round to nearest, or to even if equidistant (this is the initialized state)"

Therefore, if you are storing a value something like 13.67546 as an integter, it would round it to 14 before storing it, unless you would have changed the RC field of the control word to "truncating". The eventual value displayed would also then be 14.785 according to the code you posted.

If you don't want to start modifying that RC field, there are other precautions you must take to insure getting the correct integer. There are several options.

Oh, right. I have it set for truncating mode. :8).

P.S. Really nice website for floating point stuff. :U
Title: Source is attached to the stable baseline thread.
Post by: nixeagle on May 11, 2012, 12:45:10 AM
Raymond, the source to the program this is for is attached to http://www.masm32.com/board/index.php?topic=18787.msg159632#msg159632 . Feel free to check that out and let me know if I goofed the floating point stuff :bdg.
Title: Re: How do you print a floating point number?
Post by: raymond on May 11, 2012, 12:56:09 AM
Since you seem interested in minimal code, you may also want to consider the following details.

- If all the values you expect to "print" are below 10,000, you could use single precision floats which still give you 7 significant digits, leaving at least 3 for the decimal portion. Even the 7th significant digit would not have much meaning anyway, and you could even consider using single precision for all cases.

- If you intend to continue using your posted code to display the three decimal digits, change the jns l to jnz l after the dec ebx. Otherwise, you print 4 digits by decrementing ebx 4 times (originally set at 3) before its value becomes negative.

- You could also consider the following for printing the decimal portion by adding one instruction and removing a few others.
   fist DWORD PTR [esp+4]        ; the integer portion of the number.
   fisub dword ptr[esp+4]        ; ****** leaves only the fractional part on the FPU ******
   mov eax, [esp+4]
   print ustr$(eax)

   print "."                      ; Print decimal point marker.

   mov ebx, 3
 l:
   mov ecx, 10
   mov [esp+4], ecx
   
   fimul DWORD PTR [esp+4]
   fist DWORD PTR [esp+4]
    fisub dword ptr[esp+4]
   mov edx, [esp+4]
   print ustr$(edx)

   dec ebx
   jnz l


I'll also have a quick look at that code.
Title: Re: How do you print a floating point number?
Post by: raymond on May 11, 2012, 02:35:57 AM
Apart from what I already indicated, the remainder of the fp stuff is relatively simple and looks OK. However, other areas are intriguing.

In your calc_variance proc, what is the purpose of that instruction:
sar ebx, 31       ; shift arithmatic right by 31

Then, in the same proc,
xor edx, edx ; we are only doing 32 bit division... discarding all high bits!

Remember that a 32-bit division divides a 64-bit value by a 32-bit value, with the proviso that the quotient must fit in a 32-bit register. You should already have your 64-bit value in EDX:EAX since you seemingly "intended" to increment the high 32-bit due to any overflow from the addition of two 32-bit values. Rezeroing the high 32-bits of your addition is counterproductive.

If you did intend to increment the high 32-bit due to any overflow from the addition or squaring of the ECX register, you MUST review that code and change it.

I've noticed that you are using the following type of instruction in numerous places:
mov ecx, gu_total_samples-1

I assume you want to load the register with the content of the memory variable decremented by 1 and use it as a counter. Have you tested if that instruction actually gives you the result you want? Unless it's some type of a macro or a specialty of the assembler you are using, such an instruction in MASM syntax may load the register with the dword starting at one byte lower than the address of the memory variable. It may be safer to load only the content without modification and jump back into the loop until it reaches 0 with the jnz opcode instead of the jns opcode.
Title: Re: How do you print a floating point number?
Post by: jj2007 on May 11, 2012, 09:30:47 AM
Hi nixeagle,

Attached a testbed for your print_float algo (no library needed).
There is an option RayMod=1 that allows to test Ray's proposal.

The output shows that there are still minor problems:
nixeagle float, Ray's mod = 0:
12.3566
1235.6600
1234568.9908
0.0054
1.2356
-123.1006

jj float, Real8:
12.346
1234.560
1234567.890123457       9 digits set
-0.0012346      7 digits set
1.235
-123.456


The *.asc file is like the *.asm but has colouring. It opens in WordPad or Ms Word.

HTH, jj :thumbu
Title: Re: How do you print a floating point number?
Post by: nixeagle on May 11, 2012, 06:22:37 PM
Quote from: jj2007 on May 11, 2012, 09:30:47 AM
Hi nixeagle,

Attached a testbed for your print_float algo (no library needed).
There is an option RayMod=1 that allows to test Ray's proposal.

The output shows that there are still minor problems:
nixeagle float, Ray's mod = 0:
12.3566
1235.6600
1234568.9908
0.0054
1.2356
-123.1006

jj float, Real8:
12.346
1234.560
1234567.890123457       9 digits set
-0.0012346      7 digits set
1.235
-123.456


The *.asc file is like the *.asm but has colouring. It opens in WordPad or Ms Word.

HTH, jj :thumbu

Other than the off-by-one error with printing 4 digits after the decimal point, I think the rest can be explained due to the control word not being set. In the actual program I set the control word to truncation mode for the whole runtime of the program. See http://www.masm32.com/board/index.php?topic=18787.msg159632#msg159632 and the attachment labeled timing-0.5.

Also I'm not real sure, at a first glance why I have funky behavior with negative numbers, but my application should never have such numbers printed. :lol.

Once I finish going through raymond's code suggestions, I'll take a second look at this :bg.