LoginSignup
1
1

More than 5 years have passed since last update.

Unity C# BigIntegerメモ

Last updated at Posted at 2017-11-22
int costTapItemLvCoefficient
int exponentiatio
// NG
returnBigInt = new BigInteger( ( ((costTapItemLvCoefficient * exponentiation) * bonusCoefficient)  ).ToString(), 10);

結果:-1121583104


// NG
returnBigInt = (costTapItemLvCoefficient * exponentiation) * 131072;

結果:-1121583104

// OK 
returnBigInt = costTapItemLvCoefficient * exponentiation;
returnBigInt = returnBigInt * 131072;

結果:3173384192

C# int 上限

int -2,147,483,648 ~ 2,147,483,647
※参考:https://docs.microsoft.com/ja-jp/dotnet/csharp/language-reference/keywords/integral-types-table

追記

BigInteger returnBigInt = new BigInteger("0",10);
int costTapItemLvCoefficient = 41152264;
int exponentiation = 205;


returnBigInt = costTapItemLvCoefficient * exponentiation;

// NG これも上限超えのマイナスになった。。
Debug.Log("returnBigInt " + returnBigInt.ToString());

BigInteger returnBigInt = new BigInteger("0",10);
int costTapItemLvCoefficient = 41152264;
int exponentiation = 205;

returnBigInt = costTapItemLvCoefficient;
returnBigInt = returnBigInt * exponentiation;

// OK 挙動がよくわからない。。
Debug.Log("returnBigInt " + returnBigInt.ToString());

試した環境

MacOS Siera

image.png

image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1