Alan Gutierrez

Alan Gutierrez blogs on software, social networks, and himself.

Subscrive Via RSS Feed

Geek Dinner

The first Geek Dinner with wine supplied by Stormhoek. This dinner will be held at Alan’s ghetto French Quarter courtyard and apartment, on July 14th, 2006 a Friday, at or about 7:00 pm.

It will take the form of a pot luck. I’ll buy as much food as my “budget” will allow, but you should all consider bringing something of your own.

Now go ahead, and RSVP. You can leave a message in the comments. I’m writing a nice document that says who is attending and who is who at the Geek Dinners page of the New Orleans Wiki.

Say Anything

I’ve not been writing much lately. Please, send me an encouraging word. I’m going to breeze through my feed reader, and look see what you all are up to.

Detroit Fireworks

My friend Stephen Goodfellow sent me the Detroit fireworks, or the fireworks of the International Freedom Festival, to be perfectly clear. What’s the reasoning behind having them so far in advance of July 1st and July 4th?

A Day At Church

Spent the day with Maitri at the Coliseum Square Baptist Church at her behest, I arrived. I’m writing this from Maitri’s Dell. Becky and I had driven past the chuch the morning. It was in the morning paper. It burned last night. This church is across the street, a block away from the Coliseum Theater that burned in February. They had a demoltion crew to raze this historic building by 7 am. Record time. It feels like home. It feels like Detroit.

Writ of Mandamus

A couple of the regulars at Cafe Rose Nicaud have filed a writ of mandamus which has been servied to Mayor Ray Nagin. What is it? Basically, it’s requesting the Mayor to come up with a redevelopment plan for the City of New Orleans, Parish of Orleans. Orleans Parish is the only Parish in Louisiana that has not developed a plan, and until they do, they are unable Community Development Block Grants and other federal funds. Post the writ tomorrow, maybe.

Beckysphere

Rebecca Houtman has begun to blog her experiences with Rails, at Under the Sofa Cushions.

Mr Gutierrez Goes to Washington

Next week on Tuesday, I’m going to addend a meeting of the Federal Election Assistance Commission as a reperesentative of Think New Orleans, to discuss voter information systems. Most of my time this week has been spent in preparation for this meeting, so I’ve not been as active in my civic work for New Orleans.

Daylight Come, Everyone Go Home

Getting back to currency. The answer is simple. sprintf('%.2f', 10.8398274982734). Except it’s wrong.

That f in '%2f' is going to get you.

Whatever ActiveRecord says about currency, MySQL does not have a currency type. It does have a decimal type, however, and I’m not sure how well that maps to the ActiveRecord currency type, because currency is a sticky wicket.

You cannot use binary floating point numbers, like the kind you’ll use by default in most computer languages, because they are binary, and when you print the decimal representation, it is going to be off by a millismidge. You can assign a value to a floating point number, and ask for it right back, and find that is is off by a wee wee bit.

That is why there are decimal types that do the arithmetic we learned in grade school. They carry that one to the ten’s place, because to drop it is to short change a pensioner somewhere, and won’t that look bad. Every penny counts!

Actually, I don’t know how they implement arbitrary precision decimal types. Paul Christmann does, and he’ll tell us all about it in the comments.

Via Google, I find a very nice article on currency at CPAN in the documenation for Math::Currency, which is a Perl module, of course. The description section nails it.

There was a rambling discussion of why binary floats don’t work for currency in a thread on comp.lang.ruby called [Using Floats for Currency]. You can color on the screen with crayons while you read it.

That thread coughs up a Money class to play with.

The long and the short of it is, most database engines have a decimal type, they may call it currency, or they may call it decimial, or they may call it George, and they may hug it and squeeze it, but they are all very much not the same, so read the documentation for your particular database engine.

This advice repeated, in this article on OnLamp.com called SQL Data Types. Here’s a story about using the decimal type in MySQL that shows you how to use it through someone else’s trial and error.

At times, in my XSLT doodles, I’ve found myself without a decimal type, but with a need to tally currency.

The simplest way to do so, and to maintian precision, was to look at the amounts as a count of pennies. Here are some C programmers talking about the pennies trick. One dollar is represented as the integer 100. Credits, debits and summations turn out A-OK.

« Previous Entries