All pastes #81622 Raw Edit

(int)double

public cpp v1 · immutable
·published 2006-07-07 18:09 UTC
rendered paste body
#include <windows.h>#include <string>#include <sstream>#include <cmath>using namespace std;int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {	int iDollar = 1;							// 1	int iCent = 15;								// 15	double dMoney = iDollar + (double)iCent / 100;				// 1.15	int iConvDollar = (int)dMoney;						// 1	double dCent = fmod(dMoney, 1) * 100;					// 15	int iConvCent = (int)dCent;						// 14, should be 15	stringstream ssText;	ssText << "Int 1 Dollar: " << iDollar << "\r\n"	       << "Int 15 Cents: " << iCent << "\r\n"	       << "Double Amount: " << dMoney << "\r\n"	       << "(int)Double Dollar: " << iConvDollar << "\r\n"	       << "Double Cents: " << dCent << "\r\n"	       << "(int)Double Cents: " << iConvCent;	string sText(ssText.str());	MessageBoxA(NULL, sText.c_str(), "Flaw", MB_OK);    return 0;}