The operation overflows at compile time in checked mode?

I really can’t know why this happen.

long bill;
long income;

public void Some(){
bill = 500000 * 15000 * 70 * 0.01;
Debug.Log(bill.ToString());
}

I met error at this point,

says The operation overflows at compile time in checked mode.

It may have something to do with you are multiplying ints together to a point that they can no longer fit the constraints of an integer : Max (2,147,483,647).
When you are multiplying all of these integers you are getting 52,500,000,000. Much bigger before the system can convert it to a long.

Therefore much like floats add a “L” to the end (Make sure it is a capital or else you may confuse it for the number 1).

Therefore :

long bill;
long income;

public void Some(){
bill = 500000L * 15000L * 70L * 0.01f;
Debug.Log(bill.ToString());
}

Myhi

yes you are right. Thanks. 500000L only also works.

and if 500000 is variable, (long)myVar is works.

No problem, I was unsure about the shorter numbers, but longs do require L