728x90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test_BigInteger : MonoBehaviour
{
public System.Numerics.BigInteger m_Damage = 1000000000000000; // 10000000000000000000
public float m_Ratio = 1.1f;
// Start is called before the first frame update
void Start()
{
CalcR(m_Damage, m_Ratio);
CalcR(100, m_Ratio);
CalcR(60000000, m_Ratio);
CalcR(3422346435, m_Ratio);
CalcP(10000000000000000000, 10);
CalcP(100, 10);
CalcP(60000000000, 10);
CalcP(82387234823, 100);
}
System.Numerics.BigInteger CalcR(System.Numerics.BigInteger value, float ratio)
{
System.Numerics.BigInteger ratio1000 = Mathf.RoundToInt(ratio * 1000);
System.Numerics.BigInteger value1000 = value * ratio1000;
var rst = value1000 / 1000;
Debug.Log($"{value:#,###} x {ratio} = {rst:#,###}");
return rst;
}
System.Numerics.BigInteger CalcP(System.Numerics.BigInteger value, System.Numerics.BigInteger per)
{
Debug.Log($"{value:#,###} + {per}% = {value + (value / 100 * per):#,###}");
return value + (value / 100 * per);
}
}
728x90
'프로그래밍 > C#' 카테고리의 다른 글
퀘스트 시스템 feat linq lookup (0) | 2021.09.29 |
---|---|
KeyCode.BackQuote = = ` (0) | 2021.09.27 |
.Net 4.0 (0) | 2021.09.14 |
Tuple (0) | 2021.09.07 |
무결성 랜덤 (Random) (0) | 2021.03.09 |
댓글