Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
20 May, 2013, 07:12:39 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 2 [3] 4 5   Go Down
  Print  
Author Topic: BigNumNum Cruncher -  (Read 3190 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
lkj
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: Today at 00:06:14
Date Registered: 07 September, 2011, 20:05:25
Posts: 348

Total Post Ratings: +40

View Profile
« Reply #30 on: 18 January, 2012, 21:26:14 »
0

The problem is that a power of two can't be odd like in the second picture.
Have you some code?
Logged

My Nspire Ndless C projects:
Hayleia
Programming Absol
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Last Login: Yesterday at 19:28:05
Date Registered: 01 June, 2011, 20:12:47
Location: ud-ud ?
Posts: 2043


Total Post Ratings: +254

View Profile
« Reply #31 on: 18 January, 2012, 21:43:17 »
0

ah, yes, a power of two that terminates by a 9 O.o
Logged





Spoiler for what I am according to...:
me: useless
Pokemon Test: an Absol
turiqwalrus: an eggplant
p2: A HUMAN BEING !
Blackpilar and p2: iplantonlyplantwantplanttoplantknowplantifplantyouplantareplantaplantboyplantorplantaplantgirlplant
click here to know where you got your last +1s
sammyMaX
LV4 Regular (Next: 200)
****
Offline Offline

Last Login: Yesterday at 00:12:41
Date Registered: 18 April, 2011, 18:01:37
Posts: 192


Topic starter
Total Post Ratings: +7

View Profile
« Reply #32 on: 19 January, 2012, 01:36:28 »
0

I actually programmed it to use the "..." when the entire output is too large to fit.
The first picture (showing 2155) is correct, while the second one, 2210, is not. I noticed that it always outputs a number with a lot of 2809's and 2810's when it's not correct.

There is a part of my program that might be screwing up. One of the parameters my power function takes in is an array of ints that will be the output.

1
int numPow(int in1[], int in2[], int output[], int in1len, int in2len)
For that parameter (called output[]), I pass it the pointer to an array, and the array has only one int in it.

1
2
int *ans = malloc(4); // One int
int ansLen = numPow(in1, in2, ans, numInts1, numInts2);
The power function keeps calling my multiplication function, and resizes the array whenever it needs to. (Now that I think about it, this might not be so smart)

I'm thinking that if the array grows too large, and it has to move to a different address, my pointer (named ans) won't update to the new address, so it will point to the old one, which is now full of garbage.

Also, (Not really related) If you have:

1
2
3
4
int a;
int b = 2000000000; // Still within range
int c = 2000000000; // Still within range
a  = (b * c) % 10000000000; // Last 10 digits of the product
Does that work, or will it cause overflow? I am wondering because right now, I am storing numbers as arrays of ints with 4 digits in each int, which is quite inefficient.
Logged


Are you wondering who Sammy is? My avatar is Sammy.
   
sammyMaX
LV4 Regular (Next: 200)
****
Offline Offline

Last Login: Yesterday at 00:12:41
Date Registered: 18 April, 2011, 18:01:37
Posts: 192


Topic starter
Total Post Ratings: +7

View Profile
« Reply #33 on: 19 January, 2012, 03:49:23 »
+1

YESSS!!!

It was what I thought - the array grew too large and the pointer ended up pointing to some random section of RAM.

Behold - the largest numbers ever computed on the Nspire!
Note: it took around 3-4 seconds to do 29001


* EPIC.png (3.46 KB, 320x240 - viewed 174 times.)
Logged


Are you wondering who Sammy is? My avatar is Sammy.
   
Hayleia
Programming Absol
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Last Login: Yesterday at 19:28:05
Date Registered: 01 June, 2011, 20:12:47
Location: ud-ud ?
Posts: 2043


Total Post Ratings: +254

View Profile
« Reply #34 on: 20 January, 2012, 22:45:55 »
0

Great job ! Cheesy
This will be very useful for arithmetics. You know when they ask you "what is the relainder when you divide 29001 by 193 ?" and you have to find a power n of 2 with 2n==1[193] because they think the calc is slow, with your engine, you just write the calculus and it is done Tongue
Logged





Spoiler for what I am according to...:
me: useless
Pokemon Test: an Absol
turiqwalrus: an eggplant
p2: A HUMAN BEING !
Blackpilar and p2: iplantonlyplantwantplanttoplantknowplantifplantyouplantareplantaplantboyplantorplantaplantgirlplant
click here to know where you got your last +1s
sammyMaX
LV4 Regular (Next: 200)
****
Offline Offline

Last Login: Yesterday at 00:12:41
Date Registered: 18 April, 2011, 18:01:37
Posts: 192


Topic starter
Total Post Ratings: +7

View Profile
« Reply #35 on: 21 January, 2012, 00:05:13 »
0

Thanks! Smiley

I do a lot of math contests, and although the Nspire has helped a lot in them (at least the ones where calculators are allowed) I always dreamed of something more powerful, something that could answer a question like, "find the sum of the digits of 800!"
Logged


Are you wondering who Sammy is? My avatar is Sammy.
   
lkj
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: Today at 00:06:14
Date Registered: 07 September, 2011, 20:05:25
Posts: 348

Total Post Ratings: +40

View Profile
« Reply #36 on: 21 January, 2012, 02:17:14 »
0

Also, (Not really related) If you have:

1
2
3
4
int a;
int b = 2000000000; // Still within range
int c = 2000000000; // Still within range
a  = (b * c) % 10000000000; // Last 10 digits of the product
Does that work, or will it cause overflow? I am wondering because right now, I am storing numbers as arrays of ints with 4 digits in each int, which is quite inefficient.

Yes, it will overflow, my compiler gives a warning.

Why do you only store 4 digits in one int, and not more?
Logged

My Nspire Ndless C projects:
sammyMaX
LV4 Regular (Next: 200)
****
Offline Offline

Last Login: Yesterday at 00:12:41
Date Registered: 18 April, 2011, 18:01:37
Posts: 192


Topic starter
Total Post Ratings: +7

View Profile
« Reply #37 on: 21 January, 2012, 16:13:40 »
0

If I store x digits per int, I only want the last x digits of a product (or sum or difference) and send the rest as a carry. That means all the numbers I get as results will be in the range of an int, but during the intermediate steps, some numbers will come out that don't fit in the integer range. For example, if I store 10 digits per int, and multiply them, the carry will be within range, and the last 10 digits will also be in range, but the product of the two numbers itself won't be. Storing 4 digits per int is the max that keeps all multiplications within range of an int.
Logged


Are you wondering who Sammy is? My avatar is Sammy.
   
steelfirez
LV1 Newcomer (Next: 20)
*
Offline Offline

Last Login: 09 February, 2012, 04:42:44
Date Registered: 12 September, 2011, 01:03:01
Posts: 8

Total Post Ratings: 0

View Profile
« Reply #38 on: 24 January, 2012, 02:47:21 »
0

That's pretty cool. I participate in math contests a lot, and this would be really helpful. I'll type up some stuff later.
Logged
sammyMaX
LV4 Regular (Next: 200)
****
Offline Offline

Last Login: Yesterday at 00:12:41
Date Registered: 18 April, 2011, 18:01:37
Posts: 192


Topic starter
Total Post Ratings: +7

View Profile
« Reply #39 on: 29 January, 2012, 01:40:21 »
+1

Version 0.16a: multiplication is around 20% faster, and a bug was fixed that allowed exponents to only be up to four digits in length.

More importantly, the exponentiation algorithm has been improved significantly - it now uses exponentiation by squaring instead of the naive method. The calculation times grow much slower now, and the difference in speed grows larger as the exponent grows. Here's a chart comparing speeds of 0.15a and 0.16a doing powers of two:


* speed.png (25.45 KB, 902x527 - viewed 115 times.)
Logged


Are you wondering who Sammy is? My avatar is Sammy.
   
sammyMaX
LV4 Regular (Next: 200)
****
Offline Offline

Last Login: Yesterday at 00:12:41
Date Registered: 18 April, 2011, 18:01:37
Posts: 192


Topic starter
Total Post Ratings: +7

View Profile
« Reply #40 on: 20 February, 2012, 21:27:27 »
0

I haven't had much time to work on my project, but Winter Break = time to code Smiley
My checklist of things to do:
1. Allow large numbers to be viewed easily
2. Program:
   a. Sum of digits
   b. Trailing zero counter
   c. Factorial
   d. nCr
   e. Division
3. Make a menu system

By the way, did anyone take the AMC 10/12? How did you do?
Logged


Are you wondering who Sammy is? My avatar is Sammy.
   
sammyMaX
LV4 Regular (Next: 200)
****
Offline Offline

Last Login: Yesterday at 00:12:41
Date Registered: 18 April, 2011, 18:01:37
Posts: 192


Topic starter
Total Post Ratings: +7

View Profile
« Reply #41 on: 22 February, 2012, 00:03:36 »
0

Version 0.17a now with sum of digits completed. Unfortunately, this function won't be very useful until I program it so that the other input lines can be used (right now you can only type in line A) Also, I changed it so each input line is identified by number instead of letter.


* sums.png (3.3 KB, 320x240 - viewed 86 times.)
Logged


Are you wondering who Sammy is? My avatar is Sammy.
   
sammyMaX
LV4 Regular (Next: 200)
****
Offline Offline

Last Login: Yesterday at 00:12:41
Date Registered: 18 April, 2011, 18:01:37
Posts: 192


Topic starter
Total Post Ratings: +7

View Profile
« Reply #42 on: 26 February, 2012, 16:46:22 »
0

I made a custom radical sign character Smiley
It currently replaces the "1" character, so that's why the version number is so funny. Tongue

Meanwhile, I removed the memory usage indicator because it would be hard to program and useless, and I'm also working on porting GMP so I don't have to use my silly slow math algorithms. If that turns out successful, I will stop using my own math functions and just focus on programming a GUI.


* Radical.png (2.97 KB, 320x240 - viewed 71 times.)
« Last Edit: 26 February, 2012, 16:47:15 by sammyMaX » Logged


Are you wondering who Sammy is? My avatar is Sammy.
   
ruler501
Crazy Freshman
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: Today at 05:54:33
Date Registered: 08 November, 2010, 02:32:33
Location: In a cave with two spots of light and lots of meat
Posts: 2381


Total Post Ratings: +49

View Profile
« Reply #43 on: 26 February, 2012, 20:03:53 »
0

Could you post the source for this? I'd like to see if I could help and/or just look at it

Great job btw
Logged


Spoiler for "Projects":
My current games I am working on our:
  I might have an improved C version of this somewhere...
pSDL too lazy too make a userbar so I'll just link to the topic i update routinely http://www.omnimaga.org/index.php?board=146.0
Spoiler for "Misc images of test things":
NerdTests.com says I'm a Dorky Nerd God.  Click here to take the Nerd Test, get geeky images and jokes, and talk to others on the nerd forum!My computer geek score is greater than 100% of all people in the world! How do you compare? Click here to find out!"<br />[url=http://www.nerdtests.com/ft_personality.php?ref=42769
[/url]
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

------END GEEK CODE BLOCK------
"KnifeOn!  Apply directly to the forehead!  KnifeOn is available without a prescription at retailers nationwide."
sammyMaX
LV4 Regular (Next: 200)
****
Offline Offline

Last Login: Yesterday at 00:12:41
Date Registered: 18 April, 2011, 18:01:37
Posts: 192


Topic starter
Total Post Ratings: +7

View Profile
« Reply #44 on: 29 February, 2012, 03:01:16 »
0

Here's the source and stuff. I work with Ndless 1.7 because it is supported by Ncubate, which I use for debugging, so sorry if it's not compatible with what you use.

* Big.zip (72.85 KB - downloaded 16 times.)
Logged


Are you wondering who Sammy is? My avatar is Sammy.
   
Pages: 1 2 [3] 4 5   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.412 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.