Ejemplo n.º 1
0
		public string ToString(int iDecimalPlaces) { //TODO: , bool bAsTrueDecimal) {
			int iBuildLengthNow=InternalValueStringBuildLength;
			if (iDecimalPlaces>DecimalPlaces) iBuildLengthNow+=(iDecimalPlaces-DecimalPlaces);
			RString sReturn=new RString(iInternalValue.ToString(),iBuildLengthNow+1); //+1 for decimal point
			//TODO: replace StringBuilder with RString
			//stringbuilder constructors: capacity,maxcapacity; string,capacity
			bool bNeg=iInternalValue<0;
			if (bNeg) sReturn=sReturn.Remove(0,1);
			while (sReturn.Length<InternalValueStringBuildLength) sReturn=sReturn.Insert(0,'0'); //InternalValueStringBuildLength+1 not used since no decimal point yet
			sReturn.Insert(sReturn.Length-DecimalPlaces,'.');
			while (sReturn.Length<iBuildLengthNow) sReturn=sReturn.Append('0');
			if (iDecimalPlaces>0) {
				sReturn.Length=(sReturn.ToString().IndexOf(".")+1+iDecimalPlaces); //+1 to include dot
			}
			else {
				sReturn.Length=(sReturn.ToString().IndexOf("."));
			}
			while (sReturn.Length>1&&sReturn[0]=='0') sReturn=sReturn.Remove(0,1);
			if (bNeg) sReturn=sReturn.Insert(0,"0");
			return sReturn.ToString();
		}//end ToString