# Puzzler183

Member

1919

540 Good

• Rank
Contributor
1. ## Is NULL's Definition Standard

The C++ standard at least says that expression will never fail. Your friend is wrong. Congratulations.
2. ## Calculating information entropy

Nevermind, figured it out... Some of the sites just lie; the correct formula was the logarithm one.
3. ## Calculating information entropy

After much Googling, I wasn't able to find a good source of information on information entropy and how to calculate it from a stream of binary data. A few of the sites I read lead me to beleive that this would work (C#): float chiSq = 0; float expected = (float) length / freq.Length; for (int i = 0; i < freq.Length; ++i) chiSq += (freq - expected) * (freq - expected) / expected; Console.WriteLine("Length: " + length); Console.WriteLine("Chi-Squared: " + chiSq); Console.WriteLine("Entropy: " + (float) length / chiSq); Where freq is the frequency table (usually 256 elements), and length is the length of the input. However, this value seems to grow arbitrarily and I was wondering how entropy bits per actual byte is calculated?
4. ## Eenie Meenie Minie, DOH! I'm a racist!

Pardon my generalization but a lot of black people call each other that. I don't care if it's non-offensive when they call each other that; it's why the word is still around (I hear it at least 100 times from black people for every time I hear it from someone else). This is the same kind of double standard that let's them have a black cultural center (whereas, if I started a white cultural center, I would be labeled a racist), etc. And this double standard exists with almost every minority (see: the Gay Games in Chicago just recently; bet I couldn't have the straight games without being labeled a homophobe). I don't hate any culture/group/race. I just feel that if minorities want equality, then they have to be equal, not more equal.
5. ## Eenie Meenie Minie, DOH! I'm a racist!

So let me get this straight. Black people still call each other niggers, but yet, they get offended when someone puts up a billboard that is obviously not racist but yet has a connection to some obscure thing from more than a century ago? Right...
6. ## Swapping substrings in C#

Well, I kind of thought about that approach, but that basically triples the amount of work I should be doing.... I guess I could just roll my own with a string builder...
7. ## Swapping substrings in C#

I've recently been using regex in C# to do my string matching and replacing, however, I can't figure out a good way to do something. I have two strings x and y, and every instance of x needs to be replaced with y and vice versa in some larger text. The problem is, I can't just do a replace all x with y and then all y with x because I'll just end up with all x's (instead of swapping them). In case I haven't made myself clear, I need to do something like this: x = "apples" y = "oranges" original text = "I like apples but hate oranges" new text = "I like oranges but hate apples" In PHP, I just did this by specifying an array of patterns and replacements but C# doesn't seem to have this option. Any ideas or will I have to do it myself?
8. ## The Ship

So I guess The Ship is coming out on Steam in a little more than an hour. Anyone going to buy it/already has?
9. ## Guidelines for Posting and Discussions in the Lounge

Don't forget MP3 BEATING COMPRESSION! Oh wait that's supposed to be in general programming.... OH WAIT.
10. ## Removing uncalled functions

There is definitely a strip unused symbols thing. Perhaps it's time to get a new (better) compiler (newer GCC is FAR better than old MSVC).
11. ## Typecasting BOOL to bool in C++

Smitty is the only one of you that read more than the thread title. And he's dead on: you're forgetting to dereference a pointer somewhere probably.
12. ## Al Gores Global Warming movie will destroy our economy!!!

Let's face it guys. LessBread is dead on. Dreddnafious Maelstrom can't even be bothered to use proper grammar (your shift key is located to the left of your z key), let alone come up with counterpoints. If you think global warm is fake, look at the HGUE losses in the ice sheets (which would, by the way, slow down the temperature rise).
13. ## Speed

Quote:Original post by JBourrie Standard C++ cross-platform way to do it That's awesome. Until you realize that the resolution of that is absolute shite... ;-)
14. ## WMP 11

And I'll keep using iTunes because WMP's library thing is positively shite. WMP works for movies though...
15. ## Hardware Help (my megahurtz are missing!)

You should probably check ur megahurtz 4 free since it looks like they've been st0l3d.