Another way, if you need to do this is use round(). It is part of BSD, so you have it available on OS X when writing in C++, and it is usually what I use when I positively, absolutely, need to round that troublesome floating point number, or my money back.
So, the routine becomes:
roundedValue = round(unroundedValue * 10^decimalValuesWanted) / 10^decimalValuesWanted;
Or, in a simpler form for 2 digits after the decimal:
y = round(x * 100.0) / 100.0;
The '.0' for your number literals are important, to ensure that you don't accidentally convert it into an int while rounding it. The good news is that in this form, you don't lose any data out of the mantissa that you weren't expecting to disappear. Of course, this has issues if you are near the upper or lower bounds of the double's exponent, and does nothing if the double has no information about digits that 'small' (such as a number with an arbitrarily large exponent, the mantissa will likely not even reach past the decimal place).
Although I do wonder why you need to remove precision before you output the number, like the poster above me.