Constructors and Destructors

Started by benthehutt, March 30, 2005, 05:15:20 PM

Previous topic - Next topic
variable names arent really stored, the name is like a human reference to an address in memory where the data is stored. You can find this by running a debugger on your code. I, like Metgod, still spend more time with C the C++, and I like to use gdb as a debugger. Other debuggers will show you this relation as well.

Good Luck!

Wilnix
alt email address: wilnix@hackphreak.org

September 04, 2005, 10:37:19 AM #31 Last Edit: September 04, 2005, 10:46:27 AM by Metgod
GMP is one way to store large numbers. As I said before, probably a library (just didn't know of any at that time). Of course, you still have the problem of memory, but it does make things a bit easier for some while ...

Check out the GNU MP BigNum Library at:

http://www.swox.com/gmp/

(And what Will says is quite true about variables and being stored. Ditto with debuggers [gdb is really nice but most can show you the same things (which happens to be loads of info!)])
"My Terminal is my Soul"

String arithmetic!  Well, that's a very slow way of doing it, but I've found that it works.  The string arithmetic library can be used instead of numbers, it makes it actually possible to store that many numbers.

Also, I've found that there is also a very easy calculation that shows when the decimals stop converging.  That is, when the algorithm is going into more and more iterations, certain decimals stop changing.  So, you store these in something like a text file, and just work with the right part of the numbers.  Though the algorithm must be restated to do this.

I'm going to try writing a simple program to calculate pi using these methods.  I'll probably use ADA though.  It seems easier to do computational stuff in ADA than in C++.  (which is what I was going to write it in)  Though I might try both, who knows.

I'll post what I got when I get it.  (Though I might be preoccupied, hopefully I'll be starting a Beowulf cluster tommorrow!)
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.

Nice idea.

I'd be curious to see the string arithmetic library (or do you mean standard functions ?). So if there is a specific one, please share the name.

I'd guess you would need a library though, since the standards can only convert so many bits (like, strtoull would be for unsigned long long, etc.).
"My Terminal is my Soul"

Oh no, it's not an actual library, I have to write it.  It's just one way I'm thinking of doing it.  I think I've got a better idea though, a guy I know told me it would prolly be easier and more efficent to use bitwise arithmetic.  Two ways he suggested were to use the java.math.BigDecimal class, or a GMP-based library like MPFR.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.

Sounds good.

Though, unless I misunderstand you, bitwise arithmetic still has the limitations of numbers capacities. But yeah, a library is probably one decent way to go. It's unfortunate systems are restricted by the architecture... What might be an idea is to check out a program that figures out pi and then see what they use. Then check another one, and gather around information.

String arithmetic might work, if you have a good algorithm to keep the limits in mind. You'd still have to have a way to keep track of numbers and even if it's a string, a larger string would be difficult to keep (or again, you have something else in mind, in which case I'd love to hear it).



"My Terminal is my Soul"

I'm looking into a buttload of source from many different opensource projects.  One of the most promising projects looks to be here:

http://www.pislice.com/wiki/Main_Page

It's a distributed pj that is trying to break 1.24 trillion digits.  Wow.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.

Neat (although I still don't know the point of that, except for the challenge).

I know you explained this before, but not being a math person, I tend to forget math things... isn't it kind of useless after so many decimal points ?

Or is this just for the fun ? I can see that definitely, but as far as usefullness, not sure ?

Anyway, keep us up posted on this one (your project).

"My Terminal is my Soul"

Ha! You should read A Mathematicians Apology by Hardy.  Of course this is mostly useless.  5 decimal places can get a man to mars, 20 can predict the orbits of all the planets with more accuracy than we will ever need.
However, many methods and ideas have sprung up from calculating pi.  New areas of math have been discovered from it and mathematicians hope to find some sort of pattern in it.  (Though, truth be told, it's been proven that a pattern will never exist in pi)

For me it's purely for fun and for learning.  I'll get to learn more math and more programming.  As far as the whole digits record thing, that's just retarded, though it does give scientists a good list of 1.24 trillion random numbers when they need it...

mmmm.....math..... ;D
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.

I think I read an article (though it was on slashdot, hehe) that says pi isn't all that random (or maybe it was the other way around).

Anyway, random numbers is another very interesting topic.

I think my favourite way is using the /dev/urandom device (or equivalent) on unix/linux based OS's. The C method really sucks .. and is anything but random (even resetting the seed with the time syscall doesn't do much).

Good RNGs are hard to find. I think that's the name of an article too (something like that anyway)... Lots of methods, but they aren't all the best I think (which is a real shame).

About pi.. I can understand your view though, even though I'm not a math person. Learning more and the fun and challenge. Sounds good to me.
"My Terminal is my Soul"

Just to clarify:

Pi is not random at all, in fact it's so precise it must use an infinite amount of digits to be expressed correctly.  However, between any two digits of pi that are spaced pretty far apart, there are about the same amount of each digit 0-9.  That's why I said it was random.

Pi is so weird, who'd a thunk it.

RANDOM PI FACT:
Given a random river in the world (let's say, the Amazon for instance) measure the distance between the two farthest points of it (the top and the bottom).  Now put this number under the actual length of the river and as the river gets older and older, that ratio approaches pi.  So, theoretically, the ratio would be exactly pi with an infinitely old river.

I'm freaked out. :o
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.

That's a pretty neat fact...

And thanks for clarifying the randomness part, I was right then, about the page I read. Honestly couldn't remember 100% which way I read it though. But it must have been that it's not random.




"My Terminal is my Soul"

SMF spam blocked by CleanTalk