이것은 분명히 작동하지 않습니다.두 개의 큰 정수에서 정확한 백분율 얻기
BigInteger Total = 1000000000000000000000000000000000000000000000000000022234235423534543;
BigInteger Actual = 83450348250384508349058934085;
string Percent = ((Decimal)100.0/Total*Actual).ToString()+"%";
질문은 정확한 백분율을 얻는 방법입니다. 현재 내가 사용
.. string sTotal = (task.End - task.Start).ToString();
BigInteger current = task.End;
string sCurrent = (task.End-current).ToString().PadLeft(sTotal.Length, '0');
Int32 maxLength = sCurrent.Length;
if (maxLength > Int64.MaxValue.ToString().Length - 1)
maxLength = Int64.MaxValue.ToString().Length - 1;
UInt64 currentI = Convert.ToUInt64(sCurrent.Substring(0, maxLength));
UInt64 totalI = Convert.ToUInt64(sTotal.Substring(0, maxLength));
Percent = (Decimal)100.0/totalI
* currentI;
당신은 더 나은 제안 할 수 있습니다?
정확한 장소를 몇 개나 지정 하시겠습니까? –
BigInteger 대신에 몇 가지 부동 소수점 유형을 사용할 수 있기를 바랍니다. 훨씬 더 좋은 것 – HopeNick
@EricLippert 56 자리 이상의 – Chris