public static CSLargeInt MultiUp(CSLargeInt baseNum, float fInc, int uAddLevel, int uGiveNum = 0, CSLargeInt targetNB = null) { if (fInc < 1 && uGiveNum > 0) { Debug.LogError("MultiUp ERROR"); } CSLargeInt nb = new CSLargeInt(baseNum); List <int> lstNbNum = nb.m_lstNum; int uInc = (int)(fInc * THOUSAND); for (int i = 0; i < uAddLevel; i++) { if (targetNB != null) { SAdd(targetNB.m_lstNum, lstNbNum); } lstNbNum[1] += uGiveNum; SMultiply(lstNbNum, uInc); lstNbNum.RemoveAt(0); if (uGiveNum > 0) { SSubtraction(lstNbNum, uGiveNum); } } nb.Trim(); return(nb); }
private CSLargeInt Multiply(int otherNum) { CSLargeInt nb = new CSLargeInt(this); SMultiply(nb.m_lstNum, otherNum); nb.Trim(); return(nb); }
public static CSLargeInt MultiUpB(CSLargeInt baseNum, int uAddLevel, CSLargeInt targetNB, CalculateDelegate func) { CSLargeInt nb = new CSLargeInt(baseNum); List <int> lstNbNum = nb.m_lstNum; for (int i = 0; i < uAddLevel; i++) { int uInc = (int)(func(i + 1) * THOUSAND); SAdd(targetNB.m_lstNum, lstNbNum); SMultiply(lstNbNum, uInc); lstNbNum.RemoveAt(0); } nb.Trim(); return(nb); }
public static CSLargeInt operator -(CSLargeInt l, CSLargeInt r) { if (!r.CheckIsBigger(l)) { Debug.LogError("NumberBase operator - :" + l + "-" + r); } CSLargeInt nb = new CSLargeInt(); List <int> lstNbNum = nb.m_lstNum; List <int> lstLeft = l.m_lstNum; List <int> lstRight = r.m_lstNum; lstNbNum[0] = lstLeft[0]; int uBorr = 0; for (int i = 1; i < lstLeft.Count; i++) { if (i >= lstRight.Count) { if (lstLeft[i] < uBorr) { lstNbNum.Add(lstLeft[i] + THOUSAND - uBorr); uBorr = 1; } else { lstNbNum.Add(lstLeft[i] - uBorr); uBorr = 0; } } else { if (lstLeft[i] < lstRight[i] + uBorr) { lstNbNum.Add(lstLeft[i] + THOUSAND - lstRight[i] - uBorr); uBorr = 1; } else { lstNbNum.Add(lstLeft[i] - lstRight[i] - uBorr); uBorr = 0; } } } nb.Trim(); return(nb); }