Author Topic: Rounding test.  (Read 948 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7532
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Rounding test.
« on: September 19, 2018, 03:27:17 PM »
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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: