CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: c4ooo on March 21, 2017, 08:00:09 pm

Title: BigDecimal 84
Post by: c4ooo on March 21, 2017, 08:00:09 pm
I am writing a program that will allow you to do maths on numbers with up to 512 significant figures, 256 before and 256 after the decimal point.
(http://i.imgur.com/1Vo9vkr.jpg)

I have a simple UI working, a rudimentary parser (only right to left order of operations, no PENTAS), and an addition algorithm. Numbers are stored in BCD.

Done:

[Some of] Todo:

For the items where i put "(how?)", i do now an algorithm that will calculate with the precision of 258 decimals.
Title: Re: BigDecimal 84
Post by: p2 on March 21, 2017, 08:03:31 pm
uuh well that's nice.
But I guess it's not possible to implement this in the OS itself so it's always used...? :/

still a really usefull tool!  :thumbsup:
Title: Re: BigDecimal 84
Post by: Snektron on March 21, 2017, 08:08:29 pm
Nice! In what language are you writing this? And do you have an indication of the speed?
regarding trig, you can find various articles on the internet, mostly they're an approximation with exponents (If you want to derive them
yourself, you'll need to use taylor polynomals ;)).
For exponents you'll only need to impelemnt ln(x) and e^(x), since you can rewrite any log(x, y) and x^y to a form using ln and e^(x). Good luck ;)
Title: Re: BigDecimal 84
Post by: E37 on March 21, 2017, 10:36:16 pm
uuh well that's nice.
But I guess it's not possible to implement this in the OS itself so it's always used...? :/
Through the use of hooks, it would definitely be able to always be used.
Is this in Axe?
Looks neat. You should post how you do the math.
Title: Re: BigDecimal 84
Post by: c4ooo on March 21, 2017, 10:51:29 pm
uuh well that's nice.
But I guess it's not possible to implement this in the OS itself so it's always used...? :/
I really don't know how the OS does math internally. Modding individual functions (add, sub etc) to use more decimals won't work becouse the OS would still use the 9 byte floats, which have 10(iirc) significant figs.

Is this in Axe?
Looks neat. You should post how you do the math.
Yep, this is in axe. I plan to make this open source once i have more stuff implemented ;)

Nice! In what language are you writing this? And do you have an indication of the speed?
regarding trig, you can find various articles on the internet, mostly they're an approximation with exponents (If you want to derive them
yourself, you'll need to use taylor polynomals ;)).
For exponents you'll only need to impelemnt ln(x) and e^(x), since you can rewrite any log(x, y) and x^y to a form using ln and e^(x). Good luck ;)
I don't have addition/division, but my guess is that it will be fine. Basically, it will always take longer for you to type the number then for the program to compute :3
Also, why would i need ln(x) if its just log(x)/log(e) :P ? As a start, i will only have base 10 log. BTW, how do i rewrite x^y as e^(x) ???

Edit: part of this post was accidentally deleted by a mod in an accident, i tried to restore it as best i could, but it might not be 100% perfect ;)
Title: Re: BigDecimal 84
Post by: DJ Omnimaga on March 22, 2017, 04:39:20 pm
Awesome job c4ooo. This could be handy. As for TI-OS hook implementation the main issue tho would be that real vars would be significantly larger if they were used by this.
Title: Re: BigDecimal 84
Post by: p2 on March 23, 2017, 10:06:06 am
uuh well that's nice.
But I guess it's not possible to implement this in the OS itself so it's always used...? :/
I really don't know how the OS does math internally. Modding individual functions (add, sub etc) to use more decimals won't work becouse the OS would still use the 9 byte floats, which have 10(iirc) significant figs.
we have a new project I see  :thumbsup:

yeah that's a huge problem there, I understand that. It's pretty sad tho as it's sometimes really usefull to be able to get such exact results ^^
how can we call ur tool and can we simply enter any long calculation and get the exact result? or is it more complicated? :)
Title: Re: BigDecimal 84
Post by: Snektron on March 23, 2017, 08:59:28 pm
Nice! In what language are you writing this? And do you have an indication of the speed?
regarding trig, you can find various articles on the internet, mostly they're an approximation with exponents (If you want to derive them
yourself, you'll need to use taylor polynomals ;)).
For exponents you'll only need to impelemnt ln(x) and e^(x), since you can rewrite any log(x, y) and x^y to a form using ln and e^(x). Good luck ;)
I don't have addition/division, but my guess is that it will be fine. Basically, it will always take longer for you to type the number then for the program to compute :3
Also, why would i need ln(x) if its just log(x)/log(e) :P ? As a start, i will only have base 10 log. BTW, how do i rewrite x^y as e^(x) ???

Because there is more information on how to implement ln(x) ;)

To rewrite x^y as a power of e you would use the fact x = e^ln(x)
x^y = (e^ln(x))^y = e^(y*ln(x)).
Title: Re: BigDecimal 84
Post by: c4ooo on March 24, 2017, 06:27:29 pm
I added subtraction/negation. I feel fairly confident that everything should work, but i would like people to try different addition / subtraction equations and see if anything breaks :P

Notes:
To subtract two numbers you can use "A-B" or "A+ (small negation sign) B"
Multiple terms don't work yet.
Since output isn't trimmed, you might see something like: "-0", "00XX" or "X.XXX000".
Only addition and negation/subtraction implemented!
Also sause is in download.
Title: Re: BigDecimal 84
Post by: DJ Omnimaga on March 24, 2017, 08:49:39 pm
I'll see later if I can give it a try. I'm pretty busy. Glad to see progress :)
Title: Re: BigDecimal 84
Post by: _iPhoenix_ on March 24, 2017, 09:01:29 pm
This is AMAZING (adds an 84 to his ever-growing list of wanted calcs)
Title: Re: BigDecimal 84
Post by: Snektron on March 25, 2017, 12:35:34 am
On a sidenote, there exists an algoritm that can eliminate a lot of work when multiplying two big numbers. It has something to do with divide and conquer.
Title: Re: BigDecimal 84
Post by: p2 on March 27, 2017, 08:51:38 am
This is AMAZING (adds an 84 to his ever-growing list of wanted calcs)
I'm shocked it wasn't there before, especially after most of hte greyscale games//tools are for the 83+/84+ family :ninja:
Title: Re: BigDecimal 84
Post by: c4ooo on March 27, 2017, 07:26:36 pm
Hmm, i was almost done implementing multiplication when Doors designed to delete the program that had all the arithmetic code x.x . I had axe backup disabled cause it's really glitchy in the new version. Luckily when i transferred the program to my computer i made a backup of the code, so it shouldn't be a big setback.
Title: Re: BigDecimal 84
Post by: c4ooo on March 29, 2017, 11:07:43 pm
Ok, i have added multiplication :)
I am not sure how to do Division efficiently though.

Sause in download.
Title: Re: BigDecimal 84
Post by: DJ Omnimaga on March 31, 2017, 12:32:10 am
Ooh nice. I kinda lost touch with many projects lately, gonna download this now so I can try it later. Glad to see this coming along nicely without too much hassle. How is the speed?