I'm having trouble understanding why this code doesn't work. I am copying almost verbatim from msdn help for the setw iomanip library function. It should set the base for output, but it isn't.
I'm having trouble understanding why this code doesn't work. I am copying almost verbatim from msdn help for the setw iomanip library function. It should set the base for output, but it isn't.
Change those doubles to longs. What are your results?
Similarly, what if you changed one of the double values to 16.5 instead of 16.0? What would you have expected your output to be?
Regards,
Paul McKenzie
Last edited by Paul McKenzie; March 30th, 2010 at 11:11 PM.
I assumed that the doubles would get converted to the proper base, but apparently cout and setbase don't play that well enough together as to accept a non-integral type. Luckily, I don't need the fractional values, so I can truncate with a cast to long.
Bookmarks