April 15, 2021, 03:52:42 AM

Author Topic: Constructors and Destructors  (Read 30503 times)

0 Members and 1 Guest are viewing this topic.

Offline wilnix

  • mv user /dev/null
  • Administrator
  • Forum Hero
  • *****
  • Posts: 690
  • Country:
  • Gender: Male
  • You're not the fastest packet in the subnet...
    • Wilnix - The NetAdmin's Resource
Re:Constructors and Destructors
« Reply #30 on: September 04, 2005, 05:11:13 AM »
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

Offline Metgod

  • the deranged hacker
  • Administrator
  • Forum Hero
  • *****
  • Posts: 1116
  • Country:
  • Gender: Male
Re:Constructors and Destructors
« Reply #31 on: September 04, 2005, 10:37:19 AM »
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!)])
« Last Edit: September 04, 2005, 10:46:27 AM by Metgod »
"My Terminal is my Soul"

Offline benthehutt

  • Global Moderator
  • Seasoned Poster
  • *****
  • Posts: 368
  • Country:
  • "Drugs? You'd better not be!" - my mom
    • Echelon9
Re:Constructors and Destructors
« Reply #32 on: September 10, 2005, 12:10:30 AM »
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.

Offline Metgod

  • the deranged hacker
  • Administrator
  • Forum Hero
  • *****
  • Posts: 1116
  • Country:
  • Gender: Male
Re:Constructors and Destructors
« Reply #33 on: September 10, 2005, 11:06:30 AM »
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"

Offline benthehutt

  • Global Moderator
  • Seasoned Poster
  • *****
  • Posts: 368
  • Country:
  • "Drugs? You'd better not be!" - my mom
    • Echelon9
Re:Constructors and Destructors
« Reply #34 on: September 11, 2005, 11:28:40 AM »
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.

Offline Metgod

  • the deranged hacker
  • Administrator
  • Forum Hero
  • *****
  • Posts: 1116
  • Country:
  • Gender: Male
Re:Constructors and Destructors
« Reply #35 on: September 11, 2005, 06:54:10 PM »
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"

Offline benthehutt

  • Global Moderator
  • Seasoned Poster
  • *****
  • Posts: 368
  • Country:
  • "Drugs? You'd better not be!" - my mom
    • Echelon9
Re:Constructors and Destructors
« Reply #36 on: September 11, 2005, 08:03:24 PM »
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.

Offline Metgod

  • the deranged hacker
  • Administrator
  • Forum Hero
  • *****
  • Posts: 1116
  • Country:
  • Gender: Male
Re:Constructors and Destructors
« Reply #37 on: September 11, 2005, 09:08:37 PM »
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"

Offline benthehutt

  • Global Moderator
  • Seasoned Poster
  • *****
  • Posts: 368
  • Country:
  • "Drugs? You'd better not be!" - my mom
    • Echelon9
Re:Constructors and Destructors
« Reply #38 on: September 12, 2005, 12:24:16 AM »
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.

Offline Metgod

  • the deranged hacker
  • Administrator
  • Forum Hero
  • *****
  • Posts: 1116
  • Country:
  • Gender: Male
Re:Constructors and Destructors
« Reply #39 on: September 12, 2005, 08:31:52 PM »
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"

Offline benthehutt

  • Global Moderator
  • Seasoned Poster
  • *****
  • Posts: 368
  • Country:
  • "Drugs? You'd better not be!" - my mom
    • Echelon9
Re:Constructors and Destructors
« Reply #40 on: September 12, 2005, 10:06:12 PM »
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.

Offline Metgod

  • the deranged hacker
  • Administrator
  • Forum Hero
  • *****
  • Posts: 1116
  • Country:
  • Gender: Male
Re:Constructors and Destructors
« Reply #41 on: September 13, 2005, 09:22:39 AM »
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"