News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Hyper (precision) numeric data type

Started by i Z !, October 15, 2023, 07:38:52 PM

Previous topic - Next topic

raymond

Quote... after you wrote the procedure for sqrt :)

 :joking:  :thumbsup:
Whenever you assume something, you risk being wrong half the time.
http://www.ray.masmcode.com

i Z !

#31
@NoCforMe @raymond
I think I have (at least partial) solutions to both of your questions - New(string) initializer added in the new version, so now you can input just about any number in decimal format (updated on GitHub).

I already tried it with 1000 decimals-long pi value and it worked well. The thing was that this horsesh*t of a Git interface in VS made that code to be deleted. It said "you can't push this repo because bla bla... use Sync to...". Then I clicked Sync, but it doesn't say which way it will sync, then, with no warning deleted the entire local solution. Luckily, it was only a few lines of code. Anyway I think I learnt how to deal with GitHub now.

NoCforMe

GitHub = another thing I sincerely hope I never have to deal with in my lifetime ...
Assembly language programming should be fun. That's why I do it.

i Z !

After nearly a week,

32 clo(w)ners cloned the git repo 86 times. Practically an empty project...

TWO people in total downloaded the actual library, but the previous version... ;)

i Z !

I'm writing an installation app for it. Not because I'd expect more people to use it, but just for the heck of it :)

i Z !

#35
I had to refresh a bit about handling the registry entries...
Don't worry, my OS survived the installer tests  :azn:
I also tested it with Windows App Cert Kit - Passed with warnings
https://marketplace.visualstudio.com/items?itemName=SilverfoxSystems0.Hyper

jack

hi i Z !
in what language was the Hyper dll written ?

i Z !

#37
hi Jack, in VB.NET

jj2007

Quote from: i Z ! on November 01, 2023, 05:59:43 AMhi Jack, in VB.NET

Attention, don't click the link. The new improved version of the SMF forum software adds links to known web extensions like garbage.net or garbage.inc, so you may randomly end up with strange pages like Windows.inc

I learnt to avoid that trap by using another "i": Windows.ìnc - no link :biggrin:

jack

thank you jj  :smiley:
thank you i Z !, btw it appears that your dll is debug build, you can't use it to compile release test-code  :smiley:
PS I don't like installers, if it can be helped I would rather have zip archive

jack

@i Z !
here's my algorithm for MP division in pseudo code
function fpinverse(m as Hyper, precision as long) as Hyper
dim x as double
dim i, lim, ex, prec as long
dim as Hyper r, r2, one, n
n = m
lim = log(precision*0.0625) * 1.5 ' 1.5 = 1/ln(2) + a little extra
' get the most significant digits of m into x without the exponent, because a Hyper number's exponent can quickly exceed the range of double
' get the exponent in base 10 of m into ex
If x = 0 Then print "Division by 0": return r 'Exit Function
' the following is to avoid the pitfall when m is very close to 1, e.g. 0.999999999...
If x = 1 andalso ex=0 Then
r=Hyper("1")
return r
elseif x=1 then
x=10
ex-=1
end if
ex=(-1)-ex 'in your case probably ex = -ex
x=1/x
r=Hyper(x)
r.exponent=ex
one=1
r2=r
prec=8 'start with precision 8 (it's multiplied in the loop)
for i=1 to lim
prec=2*prec-1
r2=Hyper_mul(n,r, prec)
        r2=Hyper_sub(one, r2, prec)
        r2=Hyper_mul(r, r2, prec)
r=Hyper_add(r,r2, prec)
next
    return r
End Function

function Hdivide(n as Hyper, m as Hyper, precision as long) as Hyper
return n * fpinverse(m, precision)
end function

i Z !

#41
Quote from: jack on November 01, 2023, 06:19:08 AMthank you i Z !, btw it appears that your dll is debug build, you can't use it to compile release test-code  :smiley:
PS I don't like installers, if it can be helped I would rather have zip archive

no bother, I'm happy to see someone engaging in my lib :smiley:
It should be in release, what I only found was that Enable the Visual Studio hosting process option is still on. I'll uncheck that and we'll see if it helps.

I'm also gonna provide info on calls to native add, sub, mul and div procedures, so that you can begin the operation where required... I only need to decipher which argument means what  :smiley: , 'cause i was making some changes and i need to make sure that i give the correct data. Probably later in the day.

I checked your code, it looks convincing, ile try it out. While writing this post, i also found that i forgot to write proc's for adding/subtracting an Int64, next version will have them.

Besides that a direct conversion Double-->Hyper isn't supported(i nearly got it, but then abandoned debugging), I'd point out one thing:
The 'r2' block should be written as

r2 = n * r
r2.Subtract(one)
r2.Multiply(r)
r.Add(r2)
(precision can only be set in Divide op)

thanks JJ for that tip, i corrected it

i Z !


stoo23

Hi All,

QuoteAttention, don't click the link. The new improved version of the SMF forum software adds links to known web extensions like garbage.net or garbage.inc, so you may randomly end up with strange pages like Windows.inc

I learnt to avoid that trap by using another "i": Windows.ìnc - no link :biggrin:

Yes,.. this was discussed here a while ago, as well as on the SMF Support Forum.
I will re-visit the topic to see if anything has been resolved.

There may be a Mod' to alter the hyperlink behaviour.

HSE

Quote from: jj2007 on November 01, 2023, 06:07:48 AMI learnt to avoid that trap by using another "i": Windows.ìnc - no link :biggrin:

Apparently quotes also limit the automatic hyperlink: "windows.inc"
Equations in Assembly: SmplMath