News:

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

Main Menu

StrtoReal10 - String to Real10 function

Started by aw27, February 21, 2019, 07:52:04 PM

Previous topic - Next topic

raymond

QuoteThe ExactReal10toStr method

Such a title for a method to convert a REAL10 to a string is definitely prone to mislead those who don't have a good knowledge of basic mathematics, nor of the IEEE standard for floating points and their REAL accuracy. Any digit past the 19th significant one in the resulting decimal representation is strictly garbage, regardless of the accuracy of the input. Some of those 19 digits may also be garbage depending on the actual accuracy of the input.

This will always remind me of the days when an American association (of which I was a member) started to issue some of their standards in the metric system along with their U.S. units. One of the procedures required to take a 1-quart (U.S.) sample for some analysis. The metric updated document came out as requiring a 0.95 liter sample!!!!!!
Whenever you assume something, you risk being wrong half the time.
https://masm32.com/masmcode/rayfil/index.html

aw27

The meaning here is the following:
Every floating point value is stored as a rational number a/b where b is a power of 2. This number in turn has its exact decimal representation and this is what the program displays.
The decimal representation is as precise as the stored binary representation.
I am not talking about the precision of the stored rational number, the idea is to look at the matter from a different angle.  8)

raymond

Please don't take me wrong. I appreciate the work you did on this.

However, I'm only insinuating that a lot of people consider exact = precise, and in that sense the title could be very misleading.
Whenever you assume something, you risk being wrong half the time.
https://masm32.com/masmcode/rayfil/index.html

aw27

Quote from: nidud on February 23, 2019, 07:10:44 AM
:biggrin:
Asmc converts to quad float and scale down (faster):
https://github.com/nidud/asmc/tree/master/source/lib32/quadmath
I don't think your ldtoquad works as expected but is small and looks nice.  :biggrin:
What I mean is that I tested with 2 other different methods which agree between them but disagree with yours.


aw27

Quote from: raymond on February 26, 2019, 04:05:48 AM
However, I'm only insinuating that a lot of people consider exact = precise, and in that sense the title could be very misleading.
I appreciated your comments and I know some people may interpret it that way. Thank you.  :t

nidud

#20
deleted

aw27

I have never used asmc and am not going to learn just for this. If you don't provide instructions for a dummy to build a simple example I will have to pass.
I tested the below x86 dtoquad and the number was a PI approximation. The results were not as expected.

dtoquad proc uses ebx p:ptr, ld:ptr
   mov eax,p
    mov ecx,ld
    mov dx,[ecx+8]
    mov [eax+14],dx
    mov edx,[ecx+4]
    mov ecx,[ecx]
    shl ecx,1
    rcl edx,1
    mov [eax+6],ecx
    mov [eax+10],edx
    xor ecx,ecx
    mov [eax],ecx
    mov [eax+4],cx
    ret
dtoquad endp


nidud

#22
deleted

guga

Quote from: nidud on February 26, 2019, 11:03:16 AM
Well, it works like this:

n equ <3.141592653589793238462643383279502884197169399375105820974945>
       
.data
    real2  n ; 0x4248
    real4  n ; 0x40490FDB
    real8  n ; 0x400921FB54442D18
    real10 n ; 0x4000C90FDAA22168C235
    real16 n ; 0x4000921FB54442D18469898CC51701B7
; ldtoquad() ; 0x4000921FB54442D1846A000000000000


What did you expect?

Very very good work, Nidud.  :t :t

Same result as in:

https://rosettacode.org/wiki/Arithmetic-geometric_mean/Calculate_Pi

Well...on the link they do it for pi from thousands of digits :dazzled: :dazzled: :dazzled: :dazzled:, but your result for Pi is the same as used with Julia. :t :t :t :t :t

It i also the same result as here  :t :t :t :t :t:
https://www.perlmonks.org/?node_id=992580;displaytype=selectcode
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

aw27

Some guy produced an article Reading binary floating-point numbers with a function cvt_num10_num16(unsigned char *dest, const unsigned char *src) that I now see is wrong. Strangely, I found an alternative in asm, along the same lines.
Nidud code is indeed correct.  :t


guga

Nice finding, AW.

The fast sqrt seems very handy

for Real4
https://cs.uwaterloo.ca/~m32rober/rsqrt.pdf

for Real8
https://stackoverflow.com/questions/11644441/fast-inverse-square-root-on-x64

I wonder, if the precision can be increased as well. Seems interesting (and fast)
https://github.com/herumi/misc/blob/master/rsqrt.cpp
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com