Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
narbsy
Jun 2, 2007
Victor, you are thinking too advanced.

The only way to program is to create an analytical machine in the form of a difference engine to do it for you!

No need for messy punch cards, only pure determination and genius. Lots of genius. I'd love to see dynamic programming on one of these babies. Also, far less writing and punching than cards.

Adbot
ADBOT LOVES YOU

narbsy
Jun 2, 2007
if you're doing an in-class example and want to make sure everyone knows what you're doing... then this is better than a for loop due to clarity, at least in my opinion.

narbsy
Jun 2, 2007

RegonaldPointdexter posted:


Probably because
code:
malloc(sizeOf(something))
is hardwired in your brain if you're a C coder.

it's sizeof in C, case sensitive...

narbsy
Jun 2, 2007

JoeNotCharles posted:


That happens to work because ints and pointers are the same size

Only on 32-bit machines...


e: Also true. My mistake.

narbsy fucked around with this message at 04:00 on Oct 7, 2008

narbsy
Jun 2, 2007

tripwire posted:

God I hate hungarian notation. How in the hell did anyone ever think it was a smart idea :psyduck:

Ask nebby!

narbsy
Jun 2, 2007

hexadecimal posted:

Personally, I like to do if( n&1 ) to check of it is odd or not. It is probably a lot faster than % operator.

hexadecimal, with each of your posts how you got into a masters program becomes more of a mystery.

narbsy
Jun 2, 2007

rjmccall posted:

Folly of microbenchmarks, I think. Your benchmark time is probably dominated by loop and general interpretation overhead. What did you run it in?

Uhhhhhhh it's the same loop.

I ran a simple benchmark in C; without any optimizations, & is faster than %. With -O3 they are essentially the same.

narbsy
Jun 2, 2007

minato posted:

Why do you consider &1 to be silly? Is it code clarity, performance, portability, or something else?

Code clarity I could understand, and same goes for performance unless we're talking about some highly-optimized graphics rendering loop, but I can't imagine anyone seriously citing portability.

I'd consider it silly for two reasons, the first of which being that it is unclear to use a bitwise operation to determine even/oddness instead of using modulo as is convention, and also because it falls under the category of if(p), which has been mentioned as it too assumes 0 is false. The second reason is that if the code is C, as hexadecimal was thinking of, the performance benefit really isn't large. It doesn't show up much on un-optimized code, and barely at all under optimized code.

narbsy
Jun 2, 2007

Painless posted:

Hrm good sir I think you are wrong, allow me a moment to write a two-page refutation of this complete with references (with exact page numbers) to the C99 standard, the C++98 standard, the ANSI C standard and the C++0x draft.

One can find everything in the C++0x draft, so that may not help your case. It's "Programming with Everything but the Kitchen Sink, but We Threw One In Anyways" in one document.

narbsy
Jun 2, 2007

hexadecimal posted:

Lol yea I know, right? I coded this as fast as I could at the time to meet the dead line and and didn't give it much thought.

But why did you think of !(x^y) before (x == y)??????

narbsy
Jun 2, 2007

TRex EaterofCars posted:

I couldn't even venture a guess. Probably some rear end in a top hat making things more complex than they need be to justify how smart they are.

"I'm bored and this is all I have to do! Let's see how many lines of code I can make it..."

narbsy
Jun 2, 2007

Avenging Dentist posted:

oh fabulous, a tired talking point about an easy-to-diagnose problem that only occurs when people are intentionally trying to be retarded

oh poo poo i might have to load up gdb what has this world come to

Or just plain retarded and don't understand pointers.

Adbot
ADBOT LOVES YOU

narbsy
Jun 2, 2007
Not to jump on the PHP bandwagon, but: Aspect Oriented Programming in PHP

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply