The MASM Forum

General => The Workshop => Topic started by: dedndave on June 06, 2012, 03:43:10 AM

Title: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on June 06, 2012, 03:43:10 AM
these are my Ling Long Kai Fang routines from the old forum

LLKF9_1a:
3 routines for converting arbitrary integers to ASCII decimal strings
1) unsigned
2) signed
3) unsigned/signed mode-selectable

IntExp_1:
arbitrary integer exponential routine demo

EDIT: May 2, 2013
added Evr1 - real number evaluation utility
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: jj2007 on June 06, 2012, 04:57:22 AM
Dave,
My math is not advanced enough for such stuff, but if you decide to open a startup together with Rui (Calcula), Ray (FpuLib) and qWord (SimpleMath), then I volunteer for the publicity part :biggrin:
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on June 06, 2012, 08:49:35 AM
those guys are whizzes - lol
i got these done by brute force effort and a bunch of time   :P
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: RuiLoureiro on June 07, 2012, 01:38:41 AM
Dave,
I like "Ling Long Kai Fang" !
Where did you see those names ?
Are you taking too much beers, Dave? :badgrin:
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: hutch-- on June 07, 2012, 01:41:06 AM
Rui, I think it has some to do with the guys who designed the algo.
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on June 07, 2012, 02:40:40 AM
 :biggrin:

i couldn't wait for someone to ask that question - lol

it's mentioned here
http://en.wikipedia.org/wiki/Zhu_Shijie (http://en.wikipedia.org/wiki/Zhu_Shijie)

this is the guy that named it
http://en.wikipedia.org/wiki/Qin_Jiushao (http://en.wikipedia.org/wiki/Qin_Jiushao)

it means something like "polynomial ladder solution"

it is an earlier name for Horner's Rule
http://en.wikipedia.org/wiki/Horner%27s_method (http://en.wikipedia.org/wiki/Horner%27s_method)

and - yes - too many beers   :badgrin:
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: RuiLoureiro on June 07, 2012, 04:08:24 AM
Hi Hutch,  :t
         
Dave,
       i was only kidding.
       In any way, now i know what it mean.
       yes, i need some beers too !  :badgrin:
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on June 07, 2012, 09:47:09 AM
time to open another ling long beer, eh   :t

i have learned some things since i wrote those routines
i may take  look at them to see if they could be improved upon

i might mention - they use no FPU/MMX or SSE registers
i know they could be faster if those instruction sets were used
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: hutch-- on June 07, 2012, 11:27:06 AM
haha, pisspots. REAL asm prgrammers drink Pure Malt[tm].  :P
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on June 07, 2012, 12:15:28 PM
Pure ????
that would probably taste like caca - lol
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: hutch-- on June 07, 2012, 12:26:55 PM
I guess that is what you would expect from a beer drinker  :P.  Pure Malt[tm] is what you get when you distill malted barley rather than brew it. I would not wash my socks in most beers, full of chemicals and other crap, at least Pure malt distilled in Scotland is free of the crap in beer.

I have a number of Malts that are 100 proof (50% alcohol by volume) which should never be drunk in volume unless you intend to end up in the horizontal position (floorboarded).  :biggrin:
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on June 08, 2012, 12:42:12 AM
back in the day, we could get Foster's here that was just as it was sold in Australia
now days, you can only get the import variety which is 6% or something   :(
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on May 03, 2013, 02:13:52 AM
i have added a new attachment to the first post of the thread
happy ling long kai fang !   :biggrin:

C:\ > Evr
Evr: Ling Long Kai Fang Real Number Evaluation Utility
DednDave  5-2013  Ver 1.0

  This program evaluates hexadecimal Intel real numbers from the command line.
     The characters 0-9, A-F, P, X, and S are read, all others are ignored.
  This allows the use of spaces, underscores, etc, to separate the hex digits.
If the number of hex digits doesn't total 8, 16, or 20, this message is shown.
           The P switch may be used to show values at full Precision.
   The X switch may be used to show values with 3 eXtra digits of precision.
                      The X switch overrides the P switch.
      The S switch may be used to Step the LSB, showing 3 adjacent values.
               (d) = Denormal               (p) = Pseudo-Denormal

                    Example: Evr 4000 C90F DAA2 2168 C235 xs

                         Press any key to continue ...

C:\ > Evr 4000 C90F DAA2 2168 C235 xs

4000_C90FDAA2_2168C234: +3.14159265358979323829597

4000_C90FDAA2_2168C235: +3.14159265358979323851281

4000_C90FDAA2_2168C236: +3.14159265358979323872965

C:\ > Evr 4000C90FDAA22168C235p

4000_C90FDAA2_2168C235: +3.14159265358979323851280895940618620443274267017841339111328125

C:\ > Evr 0000_80000000:00000000 s

0000_7FFFFFFF_FFFFFFFF: +3.3621031431120935059e-4932 (d)

0000_80000000_00000000: +3.36210314311209350626e-4932 (p)

0000_80000000_00000001: +3.36210314311209350663e-4932 (p)

C:\ > Evr 00000000 00000000 s

80000000_00000001: -4.9406564584124654e-324 (d)

00000000_00000000: +0

00000000_00000001: +4.9406564584124654e-324 (d)

C:\ > Evr FF800000 s

FF7FFFFE: -3.40282326e+38

FF7FFFFF: -3.40282347e+38

FF800000: -∞
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: anunitu on May 03, 2013, 09:28:39 AM
yeh Hutch real malts are the sipping kind not the shoot it down kind. In tiny little glasses to boot. and of course with your pinkie turned up like a real gent.... :t
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: Magnum on May 03, 2013, 09:44:43 AM
It uses 50% cpu on my system.

Andy
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on May 03, 2013, 10:19:49 AM
Andy
you downloaded the wrong thing - lol

the IntExp program WILL run %50
it is caclulating some very, very large numbers, far beyond the precision or range of intel floats

The program i just posted is named Evr1
it will EValuate Real numbers from command-line hex
it's pretty fast and uses very little CPU time
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: jj2007 on May 22, 2013, 07:15:49 PM
Dave,
Is that the new representation of PI using your Ling Long Kai Fang Bignum library??
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on May 22, 2013, 08:01:58 PM
as far as i know, the functions don't support spirals   :lol:

as for pi, this is as close as i can get with real10's   :biggrin:
4000_C90FDAA2_2168C234: +3.141592653589793238295968524909085317631252110004425048828125

4000_C90FDAA2_2168C235: +3.14159265358979323851280895940618620443274267017841339111328125

4000_C90FDAA2_2168C236: +3.1415926535897932387296493939032870912342332303524017333984375


i think you've seen those numbers, before
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: RuiLoureiro on May 29, 2013, 08:20:34 PM
It seems that we get only 19 correct digits

they get:                                  8 4
i get this:             3.141592653589793238 94648982840038797803572379052639007568359

4000_C90FDAA2_2168C234: +3.141592653589793238 295968524909085317631252110004425048828125

4000_C90FDAA2_2168C235: +3.141592653589793238 51280895940618620443274267017841339111328125

4000_C90FDAA2_2168C236: +3.141592653589793238 7296493939032870912342332303524017333984375
Title: Re: Ling Long Kai Fang Bignum to ASCII
Post by: dedndave on May 29, 2013, 08:24:54 PM
you must understand:

1) the value that is used for Pi is the one that is closest to the actual value of Pi
intel uses real4, real8, and real10 values that are near Pi - not equal to Pi

2) when we evaluate these real numbers, we will see the values that are nearest to Pi for that numbering system

3) by examining the adjacent values, we can see what the LSB step is

4) the numbers displayed by the Evr program are 100% correct
however, the program will display more digits than are usable

5) the actual digits of Pi are 3.1415926535897932384626433832795
3.1415926535897932385 is closer to 3.14159265358979323846 than 3.141592653589793238 or 3.141592653589793239

6) according to the documentation that i have read, if you want to be able to convert the real to decimal, then back to a real, without losing any precision, 3.14159265358979323851 should be used

well - they say 21 digits, but by examining the nearest values, we can see that 20 should be enough   :P
for values in other ranges, 21 may be required
that was the original purpose of the program - to see what changing by +/-1 LSB does