JawnV6 posted:Ugh what a stupid unreadable hack to zero out a register. I despise this 'xor trick' I believe the xor trick is vestigial. Moves use to cost a lot more CPU than exclusive or in the early Pentium/AMD days, so it was very neat at the time. EDIT: And apparently still is! \/\/ I'm not crazy! Jo fucked around with this message at 07:47 on Sep 1, 2008 |
|
# ? Aug 30, 2008 03:19 |
|
|
# ? May 14, 2024 08:32 |
|
Jo posted:I believe the xor trick is vestigial. Moves use to cost a lot more CPU than exclusive or in the early Pentium/AMD days, so it was very neat at the time. xor eax, eax is still faster than mov eax, 0
|
# ? Aug 30, 2008 04:39 |
|
Scaevolus posted:xor eax, eax is still faster than mov eax, 0 I have no problem with xor eax, eax. Maybe it's just from staring at it repeatedly, because when I see it I immediately think "eax = 0;"
|
# ? Aug 31, 2008 03:36 |
|
This is going to be a theory type of question. I've always wanted to know how ID Software "did" the graphics for Wolfenstein3D. http://www.youtube.com/watch?v=C00n4rDUMNo There's a video of the game in action for those who have never played this amazing game. According to one website, it says they did it using Ray Tracing. However, I always thought ray tracing was a very expensive algorithm, and that Wolfenstein3D wasn't "real 3D" at all. So, how did they pull it off using early 1990s DOS technology? I'm familiar with how graphics are done today. Is there a dumbed down version of Ray Tracing they used? How do you think they "stored" the contents of the world? Did they literally shoot a ray for each pixel of the screen to see what got displayed?
|
# ? Aug 31, 2008 05:31 |
|
No. Wolf3d used 'ray-casting' to figure out how to scale 2d sprites in a 2.5d world; this involved (very roughly) shooting one ray per horizontal pixel on the screen (on period hardware, this would be between 320 and 640 rays), seeing when it hit something, and drawing the appropriate sprite(s) at the correct scale for the depth at which the ray hit. This is nowhere near as computationally intense as real raytracing.
|
# ? Aug 31, 2008 06:15 |
|
Ugg boots posted:Ugh, now I started posting on StackOverflow. It's not bad, but they're going to want to make a better "front page" because just listing off a bunch of seemingly random questions is kind of a clusterfuck. Recommended Fonts for Programming? Thank god, with this sort of crucial information I can finally ditch experts exchange.
|
# ? Aug 31, 2008 12:20 |
|
JawnV6 posted:Thank god, with this sort of crucial information I can finally ditch experts exchange. http://beta.stackoverflow.com/questions/35185/finding-a-single-number-in-a-list#35190 quote:Memory isn't always free, you know, so just because your time complexity is O(N) and mine is O(N*lgN) it doesn't mean that yours is better.
|
# ? Aug 31, 2008 13:42 |
|
There is so much wrong with the discussion on that page. edit: I can't vote up or down without reputation? How do I get that? Do I want that? edit2: I figured out how to get reputation: http://beta.stackoverflow.com/questions/36906/what-is-the-fastest-way-to-swap-values-in-c JawnV6 fucked around with this message at 16:13 on Aug 31, 2008 |
# ? Aug 31, 2008 15:00 |
|
I'm trying to write some assembly language using an instruction set that only does 8-bit x 8-bit multiplication. The issue is, there are some situations where I'll have to multiply a small number (i.e. <= 255 base 10) by a bigger number (i.e. one that takes up 16 bits) and store the result in two 8-bit registers. I think it has to do with multiplying the 8-bit number by each byte of the 16-bit number and then adding something, but I'm not sure and I can't get it to work out. Can anyone please help me out with this? Thanks.
|
# ? Aug 31, 2008 15:26 |
|
Rabbi Dan posted:I'm trying to write some assembly language using an instruction set that only does 8-bit x 8-bit multiplication. The issue is, there are some situations where I'll have to multiply a small number (i.e. <= 255 base 10) by a bigger number (i.e. one that takes up 16 bits) and store the result in two 8-bit registers. I think it has to do with multiplying the 8-bit number by each byte of the 16-bit number and then adding something, but I'm not sure and I can't get it to work out. I think this might help. It shows you how to multiply an 8 bit by a 16 bit and seems well documented. http://www.dreamincode.net/code/snippet2205.htm
|
# ? Aug 31, 2008 15:38 |
|
Runaway Five posted:I think this might help. It shows you how to multiply an 8 bit by a 16 bit and seems well documented. Thanks so much. Problem solved.
|
# ? Sep 1, 2008 07:20 |
I remember a lengthy discussion in these forums from some time ago about the merits of constant/static/final variables versus using #defines in a language. Correct me if I'm mistaken: #define or set_name or whatever for a compiled language makes its way into the executable code while constant final static makes its way into a register. Is there really any performance difference in the grand scheme of things?
|
|
# ? Sep 1, 2008 07:50 |
|
Jo posted:Correct me if I'm mistaken: #define or set_name or whatever for a compiled language makes its way into the executable code while constant final static makes its way into a register. Is there really any performance difference in the grand scheme of things?
|
# ? Sep 1, 2008 14:11 |
|
Jo posted:Correct me if I'm mistaken: #define or set_name or whatever for a compiled language makes its way into the executable code while constant final static makes its way into a register. Is there really any performance difference in the grand scheme of things? Nothing in this paragraph is correct.
|
# ? Sep 1, 2008 14:11 |
|
Jo posted:I remember a lengthy discussion in these forums from some time ago about the merits of constant/static/final variables versus using #defines in a language. This is correct. #defines never make it past the L1 cache, due to register pressure.
|
# ? Sep 1, 2008 14:22 |
|
Aw man, I'm under so much register pressure these days, I can hardly get it up.
|
# ? Sep 1, 2008 15:06 |
|
Jo posted:Correct me if I'm mistaken: #define or set_name or whatever for a compiled language makes its way into the executable code while constant final static makes its way into a register. Is there really any performance difference in the grand scheme of things? The difference is that, in C++ for example, #defines don't respect type or scope and so are generally a much poorer alternative to using const variables. * The relative truth of this statement may vary from language to language.
|
# ? Sep 1, 2008 16:20 |
Glad to get my daily dose of retardation out of the way. Thank you to those who responded. I was suspicious that a #define would result in assembler like code:
code:
|
|
# ? Sep 2, 2008 03:12 |
|
Jo posted:
AT&T syntax is gross
|
# ? Sep 2, 2008 03:26 |
|
Jo posted:I was suspicious that a #define would result in assembler like This is what the optimizer is for.
|
# ? Sep 2, 2008 04:55 |
|
Can you give any examples of the following scenario? Let's someone/company/group makes an artificial intelligence-related technology. It learns and stores/saves its intelligence somehow. And it gets smarter, and does all these amazing things. Yay, everyone celebrates. What does the intelligence look like? Like if you data dump that structure and reverse engineer it, would it look like the most mathematically sound solution? Or does it look like someone designed it? Or is it a nonsensical mishmash? Know what I'm saying? Wasn't there an article on Slashdot about a helicopter learning how to fly... The flying routines it invents, are they as good as ones made by real people? Or do they do techniques that people never would have thought of?
|
# ? Sep 3, 2008 21:49 |
|
Evolutionary algorithms come up with extremely efficient solutions that often look batshit and inelegant compared to human designs. Take rotor's recently posted radio antenna, designed using an evolutionary algorithm. edit: The thread in which rotor posted this csammis fucked around with this message at 22:19 on Sep 3, 2008 |
# ? Sep 3, 2008 22:14 |
|
#include <iostream> #include <string> using namespace std; int main() { double month1Rainfall, month2Rainfall; string str; cout << "First month, " << endl; getline (cin,str); cout << "First months rainfall, " << endl; cin >> month1Rainfall; string str2; cout << "Second month, " << endl; getline (cin,str2); cout << "Second months rainfall, " << endl; cin >> month2Rainfall; return 0; } Im trying to store second months rainfall and month for a later period. However when I run this it allows me only to enter numbers for first months rainfall and letters for first month but when it comes to the second month it just "couts" everything and I cant enter anything. Why is this?
|
# ? Sep 4, 2008 01:17 |
|
Hi there Jsquared. I know someone told you in the other thread that we have a thread for small questions. And this is indead a small questions thread... but we also have a thread for c++ related small questions The problem is the second cin is not removing the end line character from the buffer. Then getline() reads from the buffer until it reaches the end of the line, which is right there, so str2 becomes "" without stopping for user input. [code] And put your code between code tags please, it looks nicer. [/code]
|
# ? Sep 4, 2008 02:50 |
|
Lexical Unit posted:Hi there Jsquared. I know someone told you in the other thread that we have a thread for small questions. And this is indead a small questions thread... but we also have a thread for c++ related small questions Ok I'll post in there from now on. But this is what I came up with code:
|
# ? Sep 4, 2008 03:45 |
|
Jsquared posted:
You're allowed to do all that in one statement. E.g. cout << foo << bar << baz << quux << endl;
|
# ? Sep 4, 2008 04:35 |
|
I've got a small code segment that's overflowing a string with the following:code:
code:
|
# ? Sep 5, 2008 15:02 |
|
unknown posted:I've got a small code segment that's overflowing a string with the following: You're not freeing the memory pointed to by p->messageid (assuming it was malloc()'d) code:
|
# ? Sep 5, 2008 15:16 |
|
unknown posted:I've got a small code segment that's overflowing a string with the following: quote:Not being a programmer, I've got to ask: Is there a better way of stopping the overflow? code:
code:
Standish fucked around with this message at 15:23 on Sep 5, 2008 |
# ? Sep 5, 2008 15:18 |
|
oops, ignore me
|
# ? Sep 5, 2008 20:33 |
|
Standish posted:Is this leaking p->messageid? Yes - it overflows by a character (pushing a null into the beginning of the next string in memory, therefore basically making it null). Of course, it compiles cleanly on a different OS version. p->messageid was created using a strdup() call earlier on in the code. Anyways, thanks for the tips/fixes!
|
# ? Sep 5, 2008 21:02 |
|
I don't know if their is currently a thread on this and if there is I am sorry. I am just breaking into programming, currently taking Intro to C Programming, and as I am sure you can guess I run into a whole lot of errors. I don't know if any goons are at all up for the challenge of helping me through AIM; realistically, I could just keep posting in the C thread but I would poo poo it up with several pages on my own accord; but if anyone is up to help me out over AIM that would be great. My screen name is BboyExom, any and all help in C would be appreciated.
|
# ? Sep 6, 2008 02:21 |
|
unknown posted:Yes - it overflows by a character (pushing a null into the beginning of the next string in memory, therefore basically making it null). Of course, it compiles cleanly on a different OS version. strdup() internally uses malloc() (or something equivalent), so the memory pointed to by the return value of strdup() is the burden of the caller to free. So you still need to free() p->messageid before you assign something else to it.
|
# ? Sep 6, 2008 02:36 |
|
Just use realloc()code:
Mustach fucked around with this message at 04:24 on Sep 6, 2008 |
# ? Sep 6, 2008 04:16 |
|
The excel thread is archived so I hope this is the right spot for this... So i'm trying to make a spreadsheet to keep track of my diet and workout routine. All I want to do is assign words a value...is this possible? For example, I created a drop down list with the fruits I eat such as banana, apple, grapefruit and so forth. So for Breakfast I would select Banana for instance. Whenever "Banana" is inserted into a cell I want it to have a value of 105, for an estimate of how many calories it has. With the ultimate end result being I've got 3 drop down lists for breakfast, lunch, and dinner and then I can do a sum of these words I want to assign values to giving me my calorie intake for the day. Is this possible? I'm probably trying to make it harder than it is. Edit: I'm using excel 2007 if this makes a difference. katkillad2 fucked around with this message at 06:40 on Sep 6, 2008 |
# ? Sep 6, 2008 06:37 |
|
katkillad2 posted:The excel thread is archived so I hope this is the right spot for this... You'll probably want one Worksheet tab being a two column table, with the left hand side the names of items like Banana and the right column containing their caloric values. Then, in your main Worksheet (your log) you'd set the formula/code for the food entry lines to look up the food in the second sheet and use that value. I don't know the exact code, but it's definitely doable
|
# ? Sep 6, 2008 10:36 |
|
Mustach posted:Just use realloc() You can't re-use a pointer passed to realloc (that's why it returns a pointer) and your call to sprintf() could still overflow buff. Also, this is very silly stuff. The dude asking the question isn't splitting the atom, he's creating a string. I have no idea why this is so confusing to people, but it scares the hell out of me to think that people get such basic things wrong. code:
|
# ? Sep 6, 2008 14:26 |
|
Plastic Jesus posted:You can't re-use a pointer passed to realloc (that's why it returns a pointer) quote:#define MAX_UINT32_AS_STR_LEN strlen("4294967295") + 1 code:
code:
Mustach fucked around with this message at 15:27 on Sep 6, 2008 |
# ? Sep 6, 2008 15:24 |
|
Plastic Jesus posted:You can't re-use a pointer passed to realloc (that's why it returns a pointer) and your call to sprintf() could still overflow buff. This is a troll, right?
|
# ? Sep 6, 2008 17:29 |
|
|
# ? May 14, 2024 08:32 |
|
I want to learn .NET basically and I'm not sure where to start. Is there any poo poo I gotta get down pat before jumping in or is it feasible to pick up a book that tells you from scratch "Hey, here's where to get started, beginners!" and learn from that? Any thoughts?
|
# ? Sep 7, 2008 03:29 |