NaN currency

NaN currency

The Daily WTF, an excellent website that I recommend everyone remotely involved in computers has a look at every now and then, has one series of posts where it shows 'strange' or 'funny' error messages from not just desktop computers, but also ATMs and other embedded devices.

One of the more recent entries of these Error'd series contained a picture that made me cringe; it showed 'NaN' for a currency value. Obviously this is an unhandled floating point error, but that's not what made me cringe.

What did make me cringe is that people who are supposed to work with shitloads of money are using floating point numbers to store monetary values. This is stupid. By their nature, floating point numbers are imprecise and inaccurate. The representation of a floating point number is an approximation. This is not the kind of thing one would like for bank transfers. "Mr Foo would like to transfer approximately €100 from his account to that of his neighbour." Err, no; it doesn't work that way.

Instead, whenever you use currency, you should use integer numbers. If your local currency is the US Dollar or the Euro or another similar currency where zero-point-something amounts of money are regularly used, work on the convention that "1" in your variable actually means ".01", or ".1", or whatever is most convenient, and make the right conversion whenever you need to do some output. Do not think you can deal with rounding errors in floating point, because you cannot.

COBOL (I can't believe I'm saying this) actually makes the latter easy, because you can create a statement that says "to output this variable, show the first three digits, then a point, then the last two digits". I believe it doesn't even have support for floating point numbers. Unfortunately this kind of thing is harder in C (and similar languages), but that doesn't mean you should just go ahead and assume that floating points are a good idea...

This is the kind of error I could accept from a first-year graduate student, but not from someone who's supposed to work with money on a daily basis.

Oh well. At least the ATM is about US Dollars, so it's not likely that it's going to be my problem any time soon.

Posted
acpi display

Dear lazyweb,

Which part of acpid is it that sends XF86Display key events to my X server? It's broken: when I suspend and then resume, it keeps sending those events over and over in an infinite loop; and since the script that I've hooked to that event takes an order of magnitude longer to run than the interval between said events, I'll just say that I find this highly annoying. I'm quite sure it's actually acpid that's sending them out, since the fix for this problem seems to be to call sudo /etc/init.d/acpid restart...

Occasionally, I don't think the ACPI daemon should be sending out these events at all (it seems to do so whenever I open or close my laptop's lid), but that's a different story...

Posted
fosdem 010

Debian @ FOSDEM '10

As I do every year, this year too I asked for a devroom and a booth at the yearly FOSDEM meeting in Brussels, Belgium.

We've been granted a booth. We've not been granted a devroom.

This is not because the organizers hate Debian, but because the organizers wish to organize things slightly differently this year. As a matter of fact, they've not granted a devroom to any distribution project.

Does that mean we can't hold talks at FOSDEM? Certainly not.

Instead of a bunch of distribution devrooms, there will be a 'distribution miniconf' that the Debian distribution has been invited in. What wasn't clear from the initial mail (at least not to me), however, was that talk proposals can already be sent in.

If you want to hold a talk about a Debian-specific subject, you should subscribe to the relevant FOSDEM mailinglist, and send your proposal there. However, do note that since it will not be a Debian-specific event anymore, that while the talk may be about something related to Debian, it should target people who may be involved with other distributions. The goal is to learn from eachother.

With that out of the way, I guess the booth will gain on importance this year, since there will not be any other Debian-specific bits anymore. As such, if people would like to come up with suggestions on what to do with it, that would be greatly appreciated. These should probably go to debian-events-eu@lists.d.o.

See you at FOSDEM,

Posted