Join us on Discord!
You can help CodeWalrus stay online by donating here.

BigDecimal 84

Started by c4ooo, March 21, 2017, 08:00:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

c4ooo

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.


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:

  • Rudimentary parser
  • Addition

[Some of] Todo:

  • Negation/Subtraction
  • Multiplication
  • Division
  • Trig functions (how?)
  • Constants e, pi, and tao
  • PENTAS ooo and parentheses
  • Logs, exponents (how?)

For the items where i put "(how?)", i do now an algorithm that will calculate with the precision of 258 decimals.

p2

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:
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

Snektron

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 ;)
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


E37

Quote from: 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...? :/
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.
  • Consoles, mobile devices and vintage computers owned: Ti83,Ti84!
I've never finished a project, there is always a way to improve!
What's my calc's name? Convert $37 to decimal. Look up that element in the periodic table. Then take the abbreviation of that element and you have it!
Look! A slime!    <(^.^)>

c4ooo

#4
Quote from: 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...? :/
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.

Quote from: E37 on March 21, 2017, 10:36:16 PM
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 ;)

Quote from: 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 ;)
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 ;)

Dream of Omnimaga

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.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

p2

Quote from: c4ooo on March 21, 2017, 10:51:29 PM
Quote from: 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...? :/
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? :)
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

Snektron

Quote from: c4ooo on March 21, 2017, 10:51:29 PM
Quote from: 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 ;)
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)).
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


c4ooo

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.

Dream of Omnimaga

I'll see later if I can give it a try. I'm pretty busy. Glad to see progress :)
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

_iPhoenix_

This is AMAZING (adds an 84 to his ever-growing list of wanted calcs)
  • Calculators owned: Two TI-84+ CE's
Please spam here: https://legend-of-iphoenix.github.io/spam/

"walruses are better than tuxedo chickens, all hail the great :walrii:" ~ me
Evolution of my avatar:

Snektron

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.
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


p2

Quote from: _iPhoenix_ on March 24, 2017, 09:01:29 PM
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:
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

c4ooo

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.

c4ooo

Ok, i have added multiplication :)
I am not sure how to do Division efficiently though.

Sause in download.

Powered by EzPortal