Reply to topic  [ 8 posts ] 
Linked list arithmetic 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
I'm guessing Fin has but have any of you used linked lists for maths with large numebrs before?

I kind of invented the idea before I knew what linked lists were and now I've realised that it's actually fairly easy (ish) to do.

Purely as an exercise I'm going to try create a largeNumber class that eclusively uses linked lists and has methods for operating on them.

Will also be very useful for keeping for future code as I have been stuck in the past whenever it comes to very large numbers.

I realise there are libraries out there for this already but I'm doing it as a learning exercise also.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Apr 13, 2011 9:37 am
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Fogmeister wrote:
I'm guessing Fin has but have any of you used linked lists for maths with large numebrs before?

I kind of invented the idea before I knew what linked lists were and now I've realised that it's actually fairly easy (ish) to do.

Purely as an exercise I'm going to try create a largeNumber class that eclusively uses linked lists and has methods for operating on them.

Will also be very useful for keeping for future code as I have been stuck in the past whenever it comes to very large numbers.

I realise there are libraries out there for this already but I'm doing it as a learning exercise also.


What language? I'd look at the BigInt class as an example, I'm not sure if a linked list is the most effective way depending on the calculations

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Wed Apr 13, 2011 2:40 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
finlay666 wrote:
Fogmeister wrote:
I'm guessing Fin has but have any of you used linked lists for maths with large numebrs before?

I kind of invented the idea before I knew what linked lists were and now I've realised that it's actually fairly easy (ish) to do.

Purely as an exercise I'm going to try create a largeNumber class that eclusively uses linked lists and has methods for operating on them.

Will also be very useful for keeping for future code as I have been stuck in the past whenever it comes to very large numbers.

I realise there are libraries out there for this already but I'm doing it as a learning exercise also.


What language? I'd look at the BigInt class as an example, I'm not sure if a linked list is the most effective way depending on the calculations

c++ but any really. I just thought of the concept of even using a string or something and processing it char by char.

I'll have a look at BigInt.

Thanks

...

Genius!

That's exactly what I was looking for!

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Apr 13, 2011 2:42 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Fogmeister wrote:
Genius!

That's exactly what I was looking for!


;)

I used it for a few of the tasks on Project Euler as it's a really useful library to have around for things like that

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Wed Apr 13, 2011 7:29 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
I had a quick play with this last night and it's soooo easy to use!

Brilliant!

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Thu Apr 14, 2011 8:50 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
LOL!

Just messing around with it to find it's limits.

700! took 1.5 seconds to calculate.
1000! took 4.7 seconds to calculate and didn't crash.

It is just sitting calculating 10000! :lol:

LOL! I gave up in the end.

It seems that the time is taken in outputting the value not in calculating it in the first place.

i.e. 10000! / 10000! doesn't take long at all.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Thu Apr 14, 2011 9:36 am
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Fogmeister wrote:
i.e. 10000! / 10000! doesn't take long at all.


If it was a little smarter it could quickly evaluate 1000!/999! = 1000 based on evaluation

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Thu Apr 14, 2011 10:38 am
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
YAY!

BigInt saved my Google Code Jam sample.

I knew it was working properly. But the numbers being used in the large version of (minimum scalar product) were too big and it was messing up the result.

BigInt fixed it :D

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Thu Apr 14, 2011 2:36 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.