Showing posts with label Source. Show all posts
Showing posts with label Source. Show all posts

24 November 2011

Boost Modf Function - Integer and Fractional Parts

Have been wanting a function in C++ that would handle finding the integer of a floating point number without integer division. The boost::math::modf function finds both the integer and fractional parts.

Also I wanted to try out this source code formatting tool for blogspot. The snippet below is a unit test written in the UnitTest++ framework.


#include <UnitTest++.h>
#include <boost/math/special_functions/modf.hpp>
using namespace boost::math;

SUITE(BOOST_MATH_MODF) {
const double pi = 3.141592653589793;
TEST(modf) {
double* pIntegerPart = new double;
CHECK_CLOSE(0.141592653589793, modf( pi, pIntegerPart ), 1e-15);
CHECK_CLOSE(3.0, *pIntegerPart, 1e-15);
delete pIntegerPart;
}
}

30 October 2011

Version Control By Example - Cool

Appreciation of good and pedagogical examples is one of my Learning Languages. A while back I came upon this website that offers a free book on version control. Everything from VCS (SVN) to DCS like Git and Mercurial is touched on in this document.

I have a quick link to Version Control By Example when I want to share Version Control or to learn something new. I even keep a pdf version on my laptop. Have a look and see if it is useful to you.