February 2007 Entries
I was just reading an article on Builder.com about exception handling and it reminded me of some of my pet peeves regarding exception handling. Don't assume you have permissions to write to the Event Log! - Many people add code to log exceptions to the Event Log however they do not add any exception handling in case it fails. This is especially true for ASP.NET as many corporate networks are severely restricting permissions. It is possible for the System.Diagnostics.EventLog.WriteEntry() to throw exceptions! The exception for permissions issue is System.Security.SecurityException. Best practice is to use a wrapper function...
One of the strangest programming concepts that I came across was working with an embedded processor, Analog Devices SHARC ADSP-21062, on a project. I was shocked when I found out the following:
sizeof(char) == sizeof(short) == sizeof(int) == 1
I didn't think this was possible, but sure enough it was. After reviewing the C standard I realized that this was allowed and the only requirement was: sizeof(char) <= sizeof(short) <= sizeof(int).
This actually had a profound affect on a later project using the same processor family when I was porting an embedded GUI, Nano-X or formerly microwindows, to that processor. The issue was...
When I was debugging communication protocols a long time ago, I would often have to convert a 32-bit integer into a 32-bit floating point number. This did not mean using atof, fscanf, _fcvt or similar function, but rather interpretting the bits as an IEEE 754 or IEC 60559:1989 floating point number. An example would be:
1.0 == 0x3F800000 (1065353216)
In the process, I wrote a tool that displays the components of the floating point number and allows you to change the raw hexadecimal bits. Here is a screen shot:
This tool was written with VB6 however I have always wanted to make a C++/WTL...
I decided to publish a short article about time zone adjustment. While it uses a Microsoft KB article as the basis for the algorithm, the interesting portion of the code actually has to do with setting the client time zone and cookies. See the article here.