Archive for the ‘Coding’ Category

Floating point precision and the sum of logs

Wednesday, September 5th, 2007

Using floating point arithmetic, in particular multiplication and division with many parameters, will sooner or later lead to either underflow or overflow (not enough bits to represent the number). This article shows a trick that in some cases can be very useful to avoid precision loss, the sum of logs. (more…)

std::numeric_limits, does it really do what you expect?

Thursday, July 12th, 2007

Can you see why the code at the bottom is working as expected for integers (integral numbers) but not doubles (or other floating point numbers for that sake)? If not, don’t worry, you are not alone. (more…)

Quick toggle between .h and .cpp files

Thursday, July 12th, 2007

When programming C++ it is a very common need to switch between the .h and .cpp file. There are no built in way to do this in Visual Studio, however it is possible to accomplish! You can either use an expensive helper program, such as Visual Assist or you can do it freely by writing a macro. (more…)