|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Magic numbers(NOT the begginer programming project) |
|
![]() jakpandora Member since: 7/12/2004 From: somewhere |
||||
|
|
||||
| hi. I recently read on another forum about something called magic numbers, in which if the program/game is using a certain amount of memory and there is a cetain amount of memory available on the computer, then the program/game will run twice as fast. is this correct? am i confusing it with something else? thanks. ______________________________ My website: Quest Networks |
||||
|
||||
![]() Radan Member since: 1/26/2003 From: Rijeka, Croatia |
||||
|
|
||||
| NO, you're confusing it! |
||||
|
||||
![]() Zahlman Moderator - Game Programming Member since: 1/9/2004 From: Toronto, Canada |
||||
|
|
||||
| You may be thinking of 'alignment issues'? I don't suppose you could link to the relevant thread? |
||||
|
||||
![]() Crazy Chicken Member since: 1/27/2004 From: United Kingdom |
||||
|
|
||||
| Say you have a simple loop somewhere in your code... for( int i=0; i<100; i++) { // do something } The number 100 is a 'magic number' and should be avoided. Instead do: const int MAX = 100; for( int i=0; i<MAX ; i++) { // do something } Hope that helps... |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| a |
||||
|
||||
![]() petewood Member since: 3/5/2002 From: Bristol, United Kingdom |
||||
|
|
||||
| See The Jargon File's definition and Wiki's MagicNumbers. -------------------------------------------------------------------------------- I caught a plane to Spain, Went to a party down a red dirt road There were lots of pretty people there, Reading Rolling Stone, reading Vogue |
||||
|
||||
![]() jakpandora Member since: 7/12/2004 From: somewhere |
||||
|
|
||||
| I dont have a link to the article. i was searching for some programming stuff in google months ago and stubled upon the artcile and cant seem to find it again. ill check out that artcile you posted, petewood. and Crazy Chicken, that code you posted wasn't really what i was looking for. what is alignment issues? is that what its called? (not magic numbers?) ______________________________ My website: Quest Networks |
||||
|
||||
![]() Rebooted Member since: 4/3/2003 From: York, United Kingdom |
||||
|
|
||||
| Alignment means aligning your data to 32 or 64 bit chunks that the CPU can handle faster thus speeding up your program. I'm not sure exactly what you meant from your orginal post however. |
||||
|
||||
![]() jakpandora Member since: 7/12/2004 From: somewhere |
||||
|
|
||||
| ok, ive never heard of that before. Ill try to clarify my original post. In the article I read, it talked about something called a "magic number". a magic number was basically if the amount of memory your program is using and the amount of memory on the computer, when added(or multiplied. i can't remeber) equal a certain number, called the magic number, Your program would then increase dramatically in performance. Was I more clear this time? I basically just want to know if something like this exists, and if it does, i wanted to know how it works. ______________________________ My website: Quest Networks |
||||
|
||||
![]() jpetrie Moderator - For Beginners Member since: 6/11/2003 From: Redmond, WA, United States |
||||
|
|
||||
| I think I know what you are talking about. Modern operating systems (e.g., Windows) run your program in a virtual address space, where as far as your program is concerned, it has the entire 32-bit range of memory to play in. It accomplishes this by organizing memory into "pages," and storing unused pages on the hard drive in a page or swap file. Pages are swapped in and out as needed. If the size of your program and all its data fits into a single page (4096 bytes usually on Windows, I think?), then the OS won't have to do lots of page swapping while your program is getting a timeslice (although it will probably still swap when your program is not running and at the beginning of your timeslice). I have my doubts as to how much performance increase you'll get by doing this, especially since 4KB is a pretty tight size restriction for a reasonably useful program. I have never heard the term "magic number" in conjunction with this. What you want to look for is probably "virtual memory." |
||||
|
||||
![]() jakpandora Member since: 7/12/2004 From: somewhere |
||||
|
|
||||
| thanks, i think that was somewhat what i was looking for. However, I am 100% positive the term that was used was "magic number", so i have my doubts as to wether this is really what i was looking for or not. I know it wasnt virtual memory, i already know what that is. Thanks for posting that, though. ______________________________ My website: Quest Networks |
||||
|
||||
![]() Zahlman Moderator - Game Programming Member since: 1/9/2004 From: Toronto, Canada |
||||
|
|
||||
| People are often imprecise with terminology for this sort of thing, or flat out make it up. Again, a link to the thread would be helpful. |
||||
|
||||
![]() owl Member since: 5/2/2001 From: Buenos Aires, Argentina |
||||
|
|
||||
| If you take a look at this google search you'll notice that LOTS of articles use the term "magic number" to describe lots of different things. "fuc.ing number" would mean exactly the same in any of those context. |
||||
|
||||
![]() jakpandora Member since: 7/12/2004 From: somewhere |
||||
|
|
||||
| ok, perhaps i mistook it for something else somehow. i dont have a link to the thread because it was actually a site i found searching through google months ago. i said it was a thread on accident. ______________________________ My website: Quest Networks |
||||
|
||||
![]() izzo Member since: 10/15/2002 From: Melbourne, Australia |
||||
|
|
||||
Quote: Heh.. owl, those are all pretty much the same concept of "magic number" though: some value that has no real definition or meaning and was apparently pulled out of nowhere. cheers sam. |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|