Search found 77 matches

by Vempele
Sat Oct 31, 2009 10:07 am UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8665
Views: 1771039

Re: ITT: We make xkcd slightly worse.

A real-world variation on 221.

Spoiler:
GetConfigSetting.png
RFC 1149.6 specifies "4" as the standard IEEE-vetted config setting.
http://forums.thedailywtf.com/forums/t/13850.aspx
GetConfigSetting.png (4.3 KiB) Viewed 8552 times
by Vempele
Wed Oct 28, 2009 9:04 pm UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8665
Views: 1771039

Re: ITT: We make xkcd slightly worse.

phlip wrote:
phpBB wrote:The selected attachment does not exist anymore.
Yeah, no.


It worked when I checked. Must have been browser cache. :oops:

Spoiler:
653
slightly-worse.gif
slightly-worse.gif (10.27 KiB) Viewed 5815 times

Spoiler:
653, 492
Drinking.png
Drinking.png (11.65 KiB) Viewed 5854 times
by Vempele
Wed Oct 28, 2009 11:04 am UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8665
Views: 1771039

Re: ITT: We make xkcd slightly worse.

Can't believe no one thought of this: 653 http://forums.xkcd.com/download/file.php?id=19178 653 , 492 http://forums.xkcd.com/download/file.php?id=19179 Workaround: attach the files, c/p the urls, delete the attachments. I hope the forum won't actually delete them the moment I submit this post...
by Vempele
Fri Oct 23, 2009 9:39 am UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8665
Views: 1771039

Re: ITT: We make xkcd slightly worse.

413
Spoiler:
Expensive.png
Hats are expensive.
Expensive.png (10.95 KiB) Viewed 8978 times

Edit: improved version:
413, 432
Spoiler:
TooExpensive.png
But I LIKED my hat!
TooExpensive.png (14.73 KiB) Viewed 8908 times
by Vempele
Thu Jun 11, 2009 6:01 pm UTC
Forum: Coding
Topic: The "IT DOESN'T WORK!" thread
Replies: 1958
Views: 549628

Re: The "IT DOESN'T WORK!" thread

max_ = -1001 ... if ( isFin( arri ) && max <= 0 ){ I think you're comparing the address of the function to NULL. if ( max_ <= t ){ Note you'll have to change this to < when you implement alpha-beta. I think all the identifiers are pretty much clear. Evidently not. :lol:
by Vempele
Wed Jun 10, 2009 4:42 pm UTC
Forum: Coding
Topic: Does 'Bing' Appeal to Porn Addicts? -Python
Replies: 2
Views: 1293

Re: Search Engine API War -Python

What's your safe search setting on Google?
by Vempele
Sat Jun 06, 2009 2:56 pm UTC
Forum: Coding
Topic: The "IT DOESN'T WORK!" thread
Replies: 1958
Views: 549628

Re: The "IT DOESN'T WORK!" thread

url is of type char* also initialized with NULL. fgets(url,250,f); Attempting to store a string at NULL is the most likely cause of your segfault, then. EDIT: I used a questionably scientific method to try and find the exact location of the segfault by commenting out all the lines and incrementally...
by Vempele
Sat Jun 06, 2009 2:24 am UTC
Forum: Coding
Topic: Bus error?
Replies: 10
Views: 3090

Re: Bus error?

InkL0sed wrote:Still leaves my question about why Macs get bus errors though.
Might be historical.
Wikipedia on Segfault wrote:Systems based on processors like the Motorola 68000 tend to refer to these events as address or bus errors.
by Vempele
Sat Jun 06, 2009 2:11 am UTC
Forum: Coding
Topic: Bus error?
Replies: 10
Views: 3090

Re: Bus error?

I think you're supposed to closedir() the directories or bad things will happen if you open too many.

Check for null pointers and check errno when you see one.
by Vempele
Wed Jun 03, 2009 3:12 pm UTC
Forum: Coding
Topic: [PYTHON][HELP] Sinus function for the decimal.Decimal class.
Replies: 5
Views: 830

Re: [PYTHON][HELP] Sinus function for the decimal.Decimal class.

dec %= 180

The period of sine is 360°, not 180°.
by Vempele
Tue Jun 02, 2009 8:08 pm UTC
Forum: Coding
Topic: Is this lock-free code correct?
Replies: 20
Views: 1571

Re: Is this lock-free code correct?

My main worry there is if the Queue.IsEmpty call can be re-ordered, which could conceivably break the "empty or consuming" invariant. It won't be reordered to the other side of a T.I.E call, if that's what you're worried about. Or, at least, the corresponding MSDN article on the Interlock...
by Vempele
Mon Jun 01, 2009 6:01 pm UTC
Forum: Coding
Topic: The "IT DOESN'T WORK!" thread
Replies: 1958
Views: 549628

Re: The "IT DOESN'T WORK!" thread

struct foo **array = malloc(n*sizeof(struct foo *)); NOOOOOOOO! Always use ptr = malloc(n*sizeof(*ptr)), anything else is bug-prone (this way, if you move the declaration and you later change the type, the code will still work correctly without touching the malloc call). Or, just use the code I put...
by Vempele
Mon Jun 01, 2009 10:01 am UTC
Forum: Coding
Topic: The "IT DOESN'T WORK!" thread
Replies: 1958
Views: 549628

Re: The "IT DOESN'T WORK!" thread

foo **array = malloc(n*sizeof(*array));
by Vempele
Mon Jun 01, 2009 9:54 am UTC
Forum: Coding
Topic: Is this lock-free code correct?
Replies: 20
Views: 1571

Re: Is this lock-free code correct?

It isn't lock-free either, as far as I can tell? I see no such guarantees in the documentation I googled? On modern processors, the methods of the Interlocked class can often be implemented by a single instruction. In this case, the xchg instruction, which will work for relatively ancient values of...
by Vempele
Wed May 27, 2009 7:45 pm UTC
Forum: Coding
Topic: Coding: Hacks and Snippets
Replies: 434
Views: 782222

Re: Coding: Hacks and Snippets

stephentyrone wrote:As long as you're depending on two's complement, this is going to be faster on almost all platforms (make appropriate substitutions for types other than int32_t):

Code: Select all

int32_t sign = INT32_C(1) | (n >> 31);

As long as signed right shift is arithmetic.
by Vempele
Tue May 26, 2009 6:13 pm UTC
Forum: Coding
Topic: Coding: Hacks and Snippets
Replies: 434
Views: 782222

Re: Coding: Hacks and Snippets

You, sir, name? wrote:

Code: Select all

#define SIGN_UNCURRIED(N, L) ( 1 - (N & (1 << L )) >> L)
#define SIGN(N) SIGN_UNCURRIED(N, sizeof(N))

Operator precedence is going to give you some nasty surprises.

SIGN(4^5);
by Vempele
Thu May 21, 2009 8:15 pm UTC
Forum: Coding
Topic: Problem with Euler problem #3 in python
Replies: 40
Views: 3239

Re: Problem with Euler problem #3 in python

I just wrote this up to simply find the primes and load them into a list, but it is taking forever to run and I cant find an infinite loop or mem leak: x=600851475143 Um, you're using an O(n) algorithm. With a largish n. Also, the billionth prime is only 22801763489. Your list is going to get _big_...
by Vempele
Mon May 18, 2009 1:31 pm UTC
Forum: News & Articles
Topic: Wolfram Alpha Tricks and Randomness
Replies: 69
Views: 10624

Re: Wolfram Alpha Tricks and Randomness

LuNatic wrote:Phooey!

But this works.

Rounding fail.
by Vempele
Sat May 16, 2009 7:28 pm UTC
Forum: Coding
Topic: Endiannessityness and Unions
Replies: 46
Views: 3000

Re: Endiannessityness and Unions

Ah, it's that sort of thing. That was my next guess, honest. Maybe adding volatile would help? Can you even do that, inside a struct definition? You can use volatile wherever you can use const, so yes. Making the union volatile should work, at least for any compiler that doesn't go out of its way t...
by Vempele
Fri May 15, 2009 10:25 am UTC
Forum: Coding
Topic: Endiannessityness and Unions
Replies: 46
Views: 3000

Re: Endiannessityness and Unions

Really? Huh. So what does MSVC actually do? I was assuming the inner struct would be padded with both the members starting on 4-byte boundaries, but otherwise work as expected... See my edit. I never actually checked, but it seems just like the kind of thing a compiler would do with undefined behav...
by Vempele
Fri May 15, 2009 10:05 am UTC
Forum: Coding
Topic: Endiannessityness and Unions
Replies: 46
Views: 3000

Re: Endiannessityness and Unions

Well yeah, but key1 is still the first 32 bits of the structure... it's just the two fields of your struct aren't both in those 32 bits. Nope. assert(sizeof(entry_t)==16); elsewhere (oops, key was supposed to be uint32_t as well, of course). Note the _only_ ways it could possibly not work are: 1. T...
by Vempele
Fri May 15, 2009 9:47 am UTC
Forum: Coding
Topic: Endiannessityness and Unions
Replies: 46
Views: 3000

Re: Endiannessityness and Unions

one slight issue: casting via using a union is technically undefined behaviour in C/C++, i'm not aware of any implementations where it wouldn't do what you think it does though. MSVC. It went something like this: // hashtable entry in a chess program struct entry_t { uint32_t key; union { struct { ...
by Vempele
Fri May 01, 2009 8:36 am UTC
Forum: Coding
Topic: Coding: Hacks and Snippets
Replies: 434
Views: 782222

Re: Coding: Hacks and Snippets

Clearly, evaluating x^=y before y^=x would mean that y is not affected by y^=x? I have no idea what you're trying to say here. snip Thanks, but I already understood that, what with having explained it in the first part of my post. Which still leaves me with no clue as to how y can be "not affe...
by Vempele
Thu Apr 30, 2009 7:57 pm UTC
Forum: Coding
Topic: Coding: Hacks and Snippets
Replies: 434
Views: 782222

Re: Coding: Hacks and Snippets

I think that's undefined. There's no sequence point between the first and the second x^=, only between x^=y and y^=x. Please elaborate on how that would matter? A sequence point, as far as I understand it, guarantees that the entire expression is evaluated, including whatever sub-expressions. Super...
by Vempele
Thu Apr 30, 2009 6:02 pm UTC
Forum: Coding
Topic: Coding: Hacks and Snippets
Replies: 434
Views: 782222

Re: Coding: Hacks and Snippets

You, sir, name? wrote:Kneel before the mighty comma operator.

Code: Select all

x^=(x^=y,y^=x)


This is like IOCCC material.

I think that's undefined. There's no sequence point between the first and the second x^=, only between x^=y and y^=x.
by Vempele
Sat Apr 25, 2009 12:13 pm UTC
Forum: Coding
Topic: The "IT DOESN'T WORK!" thread
Replies: 1958
Views: 549628

Re: The "IT DOESN'T WORK!" thread

canoemoose wrote:int main(int argv, char* argc)

int main(int argc, char *argv[])
by Vempele
Fri Apr 24, 2009 2:45 pm UTC
Forum: The Help Desk
Topic: Recovering 'corrupted' files.
Replies: 8
Views: 851

Re: Recovering 'corrupted' files.

Wright wrote:I think my usb is broken now, but before i chuck it out

Try reformatting it. There's almost certainly nothing wrong with the device itself.

The data, I guess, is hopelessly corrupted, though.
by Vempele
Wed Apr 01, 2009 8:29 am UTC
Forum: Individual XKCD Comic Threads
Topic: 0563: "Fermirotica"
Replies: 169
Views: 54890

Re: "Fermirotica" Discussion

I was actually thinking of something similar a few days ago and I asked my friend how many people does she think are having sex within a mile from us. She answered three. I was intrigued. She was probably right though, considering it was 4am in a dry county with heavy religious influence and a popu...
by Vempele
Tue Mar 24, 2009 7:53 pm UTC
Forum: Coding
Topic: Why doesn't printf have a binary %?
Replies: 26
Views: 30511

Re: Why doesn't printf have a binary %?

Given that you're not usually looking at the values stacked on on top of each other, hex is still going to be easier. I usually look at them as bitboards. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 1 0 1 1 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 and 0 0 0 0 0 0 ...
by Vempele
Tue Mar 24, 2009 11:38 am UTC
Forum: Coding
Topic: Why doesn't printf have a binary %?
Replies: 26
Views: 30511

Re: Why doesn't printf have a binary %?

stephentyrone wrote:Is it easier to see the difference between:

Code: Select all

b00111111100111000001011000111111 and
b00111111000111000001011000111111


or

Code: Select all

0x3f9c163f and
0x3f1c163f?
by Vempele
Mon Mar 23, 2009 9:30 pm UTC
Forum: Religious Wars
Topic: The 1 true style
Replies: 198
Views: 160012

Re: The 1 true style

Berengal wrote:
Vempele's sig wrote:auto fib = series!("a[n-1] + a[n]")(1, 1);

Emphasis mine.

Special case: numbers. 1,1 in Finland == 1.1 nearly everywhere else. Also note it's just two arguments rather than five.
by Vempele
Mon Mar 23, 2009 8:52 pm UTC
Forum: Religious Wars
Topic: The 1 true style
Replies: 198
Views: 160012

Re: The 1 true style

Who puts spaces after commas like this?

Code: Select all

some_func(a, b, c, d, e);
It's much harder to read and looks horrible.
by Vempele
Mon Mar 23, 2009 8:22 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9968
Views: 1949508

Re: Coding: Fleeting Thoughts

Right, forgot this was the fleeting thoughts thread. :) Deallocation: just create another allocator thread, rewind the call stack while copying to the other thread, then fix all pointers (say, the pointers are stored in a fourth thread and everything is accessed through references to those pointers)...
by Vempele
Mon Mar 23, 2009 7:59 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9968
Views: 1949508

Re: Coding: Fleeting Thoughts

Of course deallocating memory will be harder, but that's beside the point.

What is the point?
by Vempele
Sun Mar 22, 2009 8:16 pm UTC
Forum: Computer Science
Topic: Maze Breadth First Search
Replies: 18
Views: 6045

Re: Maze Breadth First Search

Depth-first with iterative deepening = breadth-first.
by Vempele
Sun Mar 22, 2009 5:19 pm UTC
Forum: Coding
Topic: The Five Generations of Programming Languages
Replies: 11
Views: 2459

Re: The Five Generations of Programming Languages

many 4th aren't even Turing complete [citation needed] SQL SQL is many? And you still need a citation. Interestingly enough, SQL is not Turing complete. -- WilliamGrosso Somebody has disputed that, but I don't have a reference. It might be a vendor-specific issue. There are extensions of SQL that a...
by Vempele
Sat Mar 21, 2009 9:54 am UTC
Forum: Coding
Topic: Sort-of dynamic array
Replies: 17
Views: 1261

Re: Sort-of dynamic array

and each time you do anything it goes through all the branches required to update its state (properties), in addition to doing whatever. What branches? If you treat it like an array, it behaves exactly like a pointer (other than deleting the memory it points to when going out of scope). Unnecessary...
by Vempele
Tue Mar 17, 2009 7:57 pm UTC
Forum: Coding
Topic: Trying to build up a string array? [ Java ]
Replies: 6
Views: 2448

Re: Trying to build up a string array? [ Java ]

well I changed the line inside the if(c2.contains(p)) to see if it would reach that line... but it didn't. nextRoom.getLocks() must be empty, then. That, or isLocked(), is therefore wrong. Oops, my bad. I missed the 'inside'. Ok I changed the code a little, but I might be going down the wrong path....
by Vempele
Tue Mar 17, 2009 4:55 pm UTC
Forum: Coding
Topic: Trying to build up a string array? [ Java ]
Replies: 6
Views: 2448

Re: Trying to build up a string array? [ Java ]

well I changed the line inside the if(c2.contains(p)) to see if it would reach that line... but it didn't.
nextRoom.getLocks() must be empty, then. That, or isLocked(), is therefore wrong.
by Vempele
Tue Mar 17, 2009 4:09 pm UTC
Forum: Coding
Topic: Sum of the digits in a number (python)
Replies: 40
Views: 16840

Re: Sum of the digits in a number (python)

You, sir, name? wrote:That's true, but it can be made into such a problem.

And sufficiently clever (existing!) compilers will do that for you, at least in simple cases.

Go to advanced search