Posts

Showing posts from July, 2008

Symmetry

Just wanted to save a nice expression I read about yesterday: 1 << n >> 1   The value returned is 2^n/2, or 2^(n-1). I just thought it looked lovely :)

On 0.999...

While trying to explain to someone that 0.999... aka 0.(9) is equal to 1 - not almost equal, but equal - one of the "arguments" he used was that recurring decimals are not really numbers, you can't do mathematical operations with them. While the idea is mind-boggling - 0.(1) is 1/9 which is a rational number - I thought of a proof that doesn't use recurring decimals: using base 9. 0.(1) 10 = (0.1) 9 (0.0) 9 + (0.1) 9 = (0.1) 9 (0.1) 9 + (0.1) 9 = (0.2) 9 (0.2) 9 + (0.1) 9 = (0.3) 9 (0.3) 9 + (0.1) 9 = (0.4) 9 (0.4) 9 + (0.1) 9 = (0.5) 9 (0.5) 9 + (0.1) 9 = (0.6) 9 (0.6) 9 + (0.1) 9 = (0.7) 9 (0.7) 9 + (0.1) 9 = (0.8) 9 Finally, (0.8) 9 + (0.1) 9 = ? Well... in any numeration base, when you finished the digits you restart at 0 and add 1 to the next order, so: (0.8) 9 + (0.1) 9 = (1.0) 9 Recasting the above in base 10, we have 0.(8) + 0.(1) = 1.0 However, in base 10 we still have a digit left, so it is equally valid to write 0.(8) + 0.(1) = 0.(9) j...

You want horror? Here's horror!

Jeff Atwood latest article, Maybe Normalizing Isn't Normal is a real beauty. If you like idiots, that is. (Cue Fabian Pascal .) This is by far the worst Jeff has ever wrote. I cannot believe that someone who claims to offer advice to programmers can say anything but "NEVER denormalize". For fuck's sake, educate yourself before you discuss a subject as anything but "hey, I heard somewhere that shooting yourself in the foot is a good idea, what do you think?". (Maybe I should have realized how smart he is when he associated with Joel "exceptions are evil" Spolsky.) Let me quote a comment that explains the problem very succinctly: Speaking from long experience, if you don't normalize, you will have duplicates. If you don't have data constraints, you will have invalid data. If you don't have database relational integrity, you will have orphan "child" records, etc. Everybody says "we rely on the application to maintain that...

Static virtual in C#

Argh, this is annoying. I need a Handler type with a virtual string GetProduct() method so that derived types "know" what product they are for. However, I don't want to have to create an instance of the actual class every time I need to ask for its product... I want it to be a virtual method. Too bad - C# doesn't allow virtual static methods. What I ended up with was this: each class derived from Handler has a read-only static string property Product, each of them returning the product that class can handle. In the method where I need that product (when populating a drop-down for example) I use reflection to get the value of the property: if  (handlerType.BaseType !=  typeof  (Handler))      return ;      var product = ( string ) handlerType.GetProperty( "Product" ).GetValue( null ,  null );   I'm not really happy with this - I miss Delphi's "class" type which allowed a much more elegant solu...

More on probabilities

This is in regards to the often-repeated saying "improbable events happen all the time" (even Dembski says that... which only serves to show that even people on "my" side can be idiots). I just read something that was so apropos of this: Heroic Law of Probabilities: One-in-a-million chances happen 9/10 (Look for it on this page , it makes more sense in context.) That is just too great for words, I will keep quoting that "law" every time the subject comes up. I have to read that story , even though I'm not a fan of Marvel stuff. (Plus, the main character has a Romanian name. Yay :P)

Speculation

I believe that the mind and the brain are distinct things, while the mind and the soul are the same. However, memory is pretty clearly located inside the brain... which means that we lose our memory when we die. That would imply that the purpose of our life here is only to educate our soul... to transform us into better people. It also means that we do not know who we were or what we did - which would be good, because otherwise a lot (most? all?) of us would have to somehow come to terms with the shame of what we did. Not really compatible with heavenly bliss. No basis in anything, really, just some idle speculation.