While attempting to convert floats precisely to Decimals the other day I was caught out by the fact that Python 2.6’s print function defers to whatever the underlying C compiler’s printf function does. This meant that on Linux I got one result when I asked for ‘%.31f’ % math.pi, and on Windows – something completely different. This lack of portability is a pain, and I had to work around it.
Category Archives: Essay
Truncation to N Decimal Places in Python
I recently needed to truncate some IEEE 754 64bit floating point numbers to a given number of decimal places. I assumed Python would have built-in support for this. Not so.
Now there are reasons for this. The primary one being that you can’t really truncate floating point numbers. Now that being said – if you need to – I present here a good way to approximate the effect.
Laserdisc Players and Comb Filters
With the recent demise of two of my Laserdisc players while writing an article about Se7en, I took the plunge and got a couple of ‘fresh’ ones. Pondering how best to make use of these players got me started thinking about comb filters. I’d always wanted to get a better comb filter to use with my older players, but never got around to doing much about it.
Having a bit of free-time and cash on my hands – I decided to do a bit of group test. During testing I managed to resurrect my two dead players (Hint: 220v players don’t work well for long on 100v !)
The following equipment will be put to the test:
- Pioneer HLD-X9
- Pioneer CLD-D925 (Dual PAL/NTSC player)
- Pioneer CLD-939 (Japanese Pioneer CLD-97)
- Farojida LD-1000 (Tweaked Pioneer CLD-99)
- Leitch DPS-575 (Timebase corrector and 3D comb filter -> SDI)
- Snell and Wilcox TBS-185 Kudos Plus (Timebase corrector and 3D comb filter -> SDI)
- Sony HX-903 LCD Television
- CYP SY-P295N S-video and composite to HDMI converter
Effectively this is a group test of all of these components, which I have seen discussed on many forums – but never actually reviewed !