Monthly archives: January, 2008

A PDA with Linux

I’m used to read PDFs while in bed, on my Acer PDA. But its tiny resolution (320×240) didn’t help a clear reading, therefore I started to look for a bigger device, it must be easy to hold but not too big. So I avoided those e-readers, and focused on PDAs with bigger resolution. And then I stumbled upon a Nokia 770 review… it is supposed to be a “Internet tablet”, but the thing that caught my attention was its screen resolution: 800×480. Luckily I have a friend who owns one, so I had a look at the device… it was interesting indeed.

I thought “Ok, I can use a N770 to read PDFs, and my Acer n50 for the rest of things (do sudokus, see pictures and record Go games)”… because I read some comments on Internet saying “it’s just a web browser, not a really PDA” (really?). I found a offer on ebay, and bought it for just 102 euros.

What a machine! The default factory configuration was a bit short of features (I reinstalled the lastest OS), but then you configure some program repositories, start to add open source applications, and discover the real power. The OS is a version of Debian. This means you can have an xterm with most of the usual commands. Moreover the graphical system can hold GTK-based programs with an easy porting. I installed some games, CGoban to record Go games, and some utilities (including a player).

The cons are that its CPU (252 MHz) is too slow, so sometimes it stops to respond for a while; and the battery lasts less than a normal PDA (actually, similar to a laptop, around 3~4 hours). So its a device for patient users (or if not, try its successor, the N800 and N810, with double speed CPU and webcam).

I can even play a game of Freeciv!
Playing Freeciv on a Nokia 770

Playing with the bits of double variables

[Most of my readers will not understand the following, but the mathematicians will love it]

A couple of years ago, a mathematician friend told me some problems he had about optimizing a program (maths calculations), asking me for suggestions. I answered with some ideas, but then he asked me about the double format, the way the computer stores a double variable, with its separated sign, mantissa and exponent (actually, IEEE 754). He was pretending to manipulate directly those parts, to improve the calculation’s speed. I didn’t help him in a clear way.

In the last few months I’ve been taking part in some programming contests, on TopCoder. Today one of the problems was really boring but at the same time really interesting. In brief, it says that the division is a computationally expensive operation, except if the divisor is a power of 2 (then you can use just bit shifts to do so). The statement asks to program a division, approximating the result using a series of divisions by powers of 2.

I tried to use bit shifts and bit masks to get the exponent of a double (keeping in mind the double binary format), but I discovered that C++ (as C) doesn’t allow bit operations with doubles.

Nevertheless later I asked in the forums, and got an interesting idea. Using an “union you bind two or more variables, sharing the same memory position. That way you can manipulate the value in memory from different angles.

Here is an example in pure C: a bad UI case

In the last year I flew 24 times. Too many times, according to those ecological footprint quizs. So I decided to give another try to the train, for my usual Barcelona-Alicante trip. Unluckily in Spain the train’s company, “Renfe”, is really prehistoric: there are always delays, tickets are expensive (domestic flights are cheaper and quicker), and is the focus of a lot of political scandals.

Last Christmas they announced a new web, with a new modern system of buying tickets, and discounts up to 60% in the normal price. So far, the reservation system was terribly bad. Can they evolve into something “normal”?

I tried to buy a return ticket, Barcelona-Alicante. Firstly, the old fares are still there. Actually there is a new thing, a Captcha that gives you access to the classical fixed prices… whenever you want to do your trip, the prices are always the same for the same trains, so why do they need to hide them under a Captcha?

But the best part is to arrive… If you want to get access to the new “web fare” (60% off), you must choose “One way” ticket at the first form. This means: you must do the process 2 times, one for your going ticket, and one for the return ticket. Later you have to find a small combo box that let you choose among the fare list… the default is the most expensive option.

Finally a frame with you bank web is opened, to verify you credit card details. You press “Ok”, and suddenly says “this train is not available”… at the end of all the process. Monkeys do better jobs.

After 2 hours I accomplished the mission, I got my ticket with a cheap price. But I suspect that it has been deliberately implemented in this weird system. I imagine people, elders, in the marketing department of Renfe, smiling at the time they say “hehe, we have offered a modern look, but we are not going to let anybody a cheap price ticket”.