#include "UT2Utils.h" /*static*/ unsigned int UT2Utils::Float2Int(float inValue) { unsigned int result = 0; if (inValue > 0.0f) { result = inValue; unsigned int decimal = (inValue - result) * 10.0f; if (decimal > 0 && Randomize(10) < decimal) result++; } return result; } /*static*/ void UT2Utils::GetRoomNumberString(int inNumber, CString& outStr) { outStr.Format("%d", inNumber); if (outStr.GetAt(0) == '-') outStr.SetAt(0, 'B'); } /*static*/ void UT2Utils::GetHourMinute(int inValue, int& outHour, int& outMinute) { outHour = inValue / 60; outMinute = inValue % 60; } /*static*/ void UT2Utils::GetMonetaryString(int inValue, CString& outStr) { BOOL isNegative = false; if (inValue < 0) { isNegative = true; inValue = -inValue; } outStr.Format("%d", inValue); int len = outStr.GetLength(); if (len > 3) { int numExtraDigits = len % 3; int numGroups = len / 3; if (numExtraDigits == 0) { numExtraDigits = 3; numGroups--; } for (int i = 0; i < numGroups; i++) { int offset = numExtraDigits + (i * 3) + i; outStr = outStr.Left(offset) + "," + outStr.Mid(offset); } } if (isNegative) outStr = "-" + outStr; }