|
Post by fwiss on Apr 19, 2011 16:50:18 GMT -5
In order to save memory in my programs, I'm trying to use bitsets and to_ulong(). Would this conversion to unsigned long during math make it redundant (as in not really saving memory)? For example
bitset<8> examplebitset;//Bitset that goes up to 255. cout << examplebitset.to_ulong();
|
|
|
Post by Supermonkey on Apr 23, 2011 13:29:06 GMT -5
What device are you targeting? If you're doing this on a PC I see no point what so ever. Even on a handheld device this seems pretty pointless!
|
|
|
Post by fwiss on May 1, 2011 8:54:30 GMT -5
Ack. 'Twas out of internets for the week. Anyhoo, what do you mean it's pointless on a PC? I'm trying to use less RAM in my variables by optimizing their mem usage. I'm targeting the PC, though.
|
|
|
Post by fwiss on May 1, 2011 9:03:21 GMT -5
And I am aware of the PC's virtually infinite RAM. On my now weak 1GB RAM, All the variables in my program take up 128 Bytes or so. I want do do such optimizing for smaller projects.
|
|
|
Post by matthew on May 1, 2011 9:19:20 GMT -5
I believe what Supermonkey might be getting at is Premature Optimization. Basically you're spending your time trying to optimize non-critical parts of your program. If your program uses slightly less RAM what noticeable performance improvements are you going to see?
|
|
|
Post by fwiss on May 4, 2011 16:27:00 GMT -5
Premature optimization insinuates that I'm not done with my project.
|
|
|
Post by Supermonkey on May 6, 2011 18:16:47 GMT -5
Premature optimization insinuates that I'm not done with my project. Not necessarily, the degree of optimization you are performing here leads me to believe you are trying to optimize at too low of a level without addressing higher level issues that could be effecting performance. I can't imagine what you are doing on a PC that requires you to be quite this memory restricted. Maybe if you provided us with some context you'd get some better answers.
|
|
|
Post by fwiss on May 6, 2011 21:02:04 GMT -5
Well, I plan on programming on a microcontroller, in truth. I heard they have lower memory than even game consoles. Just to experiment, ya know? I just got annoyed when he smallest number variable took 16 bits, when I sometimes needed a variable using only 2 bits... Anyhoo, I'm way too new to C++, and I'm doing a complete remake of my game using classes, since I don't really understand them, and my normal code looks like some low-level nonmodular code, hard to reorganize. Personally, I'd like some criticism on my coding style, but since I'm new, I feel like I'll get RTFM thrown at me left and right. Guess this really isn't a background on my question. I think I might have sounded rude in my last posts, I certainly felt rude.
Could someone help me by emailing? Or should I start a new topic for that?
|
|
|
Post by matthew on May 6, 2011 22:45:33 GMT -5
Why are you obsessed with using C++?  Is it because you think professional software developers use it for all their projects? Surely if you were developing for a micro-controller & were concerned with memory-usage you'd be using Assembly Language instead? Can't you just develop your game in Basic4GL? It would be a lot easier & the results would be pretty similar. If you do decide that you want to continue with C++ just start a new topic & we'll try & help if we can.
|
|
|
Post by Supermonkey on May 7, 2011 4:29:37 GMT -5
I think if you're interested in micrcontroller programming you need to start looking at a specific instruction set for that microcontroller and learn the assembly. We did some of this at school and there are some really good intro kits. Sadly this was years ago and i can't remember what the kits we used were called, I'll try and find out my coursework later. As far as improving your C++ goes you need to go to a dedicated forum and contribute. People will quickly critique your work if you do so and as long as you look at it as a way of improving and not a personal attack you will learn new things quickly. A quick tip for me to begin with would be to stop worrying about memory usage and learn the fundamentals so you can write clean efficient code  . [offtopic] Personally I think this whole idea that "if you don't know C++ you aren't a good programmer" thing is crazy, I know when I started out I tried to learn C++ purely because of this and I failed miserably. I know just enough C++ to keep me afloat and yet I have got on just fine.
|
|
|
Post by fwiss on May 7, 2011 8:20:54 GMT -5
Well, thank you for that! I think I'll leave this topic open, though, since it's really for reference, and if anybody's willing to answer, it would help some other people too, I hope.
|
|
|
Post by Supermonkey on May 7, 2011 9:07:56 GMT -5
Well the answer would depend on the computation being performed, it's not always going to be more beneficial. What you need to do is get a profiling tool so you can see what memory is being used at what points during the running of your app to answer this question yourself.
|
|