Posts

Showing posts with the label Programming

"Cutting edge" might cut you up

Image
We love "cutting edge" technology. We need to have the latest gadget, we need to use this new trendy framework, we need to use the latest update of our favorite software. Newer should be better, right? Actually, each new technology brings a promise of improvement and an additional hidden small risk. You are trying the new innovative painkiller drug that promises to solve your low intensity, but still disturbing, migraines . You can get a real improvement on your condition, you could get no significant improvement or, with a small probability, you could die, like in the recent drug trial in France . Indeed, that was an experimental drug, and many others that took the drug were not affected. Well, this is exactly the danger: if the really bad effects only happens with low probability, it might not even be caught in the trial period...

Sorting is computationally harder than playing chess

I will argue below that sorting of a big array, using only comparison, is inherently harder than solving the problem of choosing the best next move on a chess game. One could say that it is not fair to put in competition a big, however finite, problem like chess with an arbitrary big problem like sorting n elements. Fair enough; the interesting thing is that sorting becomes inherently harder than chess for an "n" that is way smaller than you would expect, like sorting 3000 elements. At least in theory... Sorting takes a minimum of n* log 2 (n) comparisons,  more exactly  log 2 (n!) This is about sorting "by comparison only" and can be proven in 2 step. You can skip to the "chess" part if you already know this. 1. Sorting can be done in  log 2 (n!) comparisons, that is just slightly less than n* log 2 (n). We are used to consider sorting an O (n* log 2 (n)) problem. Actually there are algorithms that can do the sorting with little less t...

The meaning of music

The meaning of music is hard to capture in words. Let's try some ideas anyway! The brain bug The brain has a natural ability to extract patterns from all the stimulus. It's a fact that we like the music that has some patterns: that is not very monotonic (boring) but not very random either, so we can continuously learn some new patterns. Somehow the brain has the illusion that it continuously learns in an accelerated rate by listening music. So music could be considered a small addiction at the first analysis.

When float does not change when incrementing - C/C++ programming

Better read: Data Consistency in Distributed System - CAP, PACELC Morality series - a heptalogy This blog is mainly focused on my Philosophical and theoretical ideas. From time to time I have practical posts that are too few to deserve a blog by themselves. I still hope my other work (like above) is even more valuable than such practical article as below. * * *   What would you expect if you increment 20 millions as float? Do you expect that it will not change at all? Check the output of the simple program below. You may know the explanation, but did you expect it to happen to such relatively small values? Output: user@ubuntu$ gcc float_inc.c ; ./a.out float has 32 bits a=20000000.000000 a+1=20000000.000000 a=16777216.000000 a+1=16777216.000000 a=16777218.000000 a+1=16777220.000000 a=16777220.000000 a+1=16777220.000000 a=16777220.000000 a+1=16777220.000000 a=16777220.000000 a+1=16777220.000000 a=16777222.000000 a+1=16777224.000000