News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Rounding test.

Started by hutch--, September 19, 2018, 03:27:17 PM

Previous topic - Next topic

hutch--

I was interested to see how far you could keep dividing a number until rounding killed it. Results are deeper than I thought it would be.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .code

    iter equ <500>

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    LOCAL num1  :REAL8
    LOCAL num2  :REAL8
    LOCAL rslt  :REAL8

    LOCAL ptxt  :QWORD
    LOCAL buff[64]:BYTE

    mov ptxt, ptr$(buff)

    mov num1, dblval(1000000000.0)
    rcall fptoa,num1,ptxt
    conout "  Original number = ",ptxt,lf

    mov num2, dblval(3.333333333333333)

    movsd xmm0, num1

  REPEAT iter
    divsd xmm0, num2
  ENDM

  REPEAT iter
    mulsd xmm0, num2
  ENDM

    movsd rslt, xmm0
    rcall fptoa,rslt,ptxt
    conout "  Returned number = ",ptxt,lf

    waitkey
    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end