C#: Numbers and Integer Math [5 of 19]

Play C#: Numbers and Integer Math [5 of 19]

The Discussion

  • User profile image
    siralomarah​med
    'int', an integer is one of the integral numeric types in C#.

    There is a difference between the integers in mathematics and the integers in C#. Integers in math represent all whole numbers and their negative counterparts, emphasising the "ALL" which represent an infinite amount of numbers. The integer 'int' in C# is limited to a size of 32 bit, which mean they are finite.

    Old school reminder of how you remember order of operations "PEMDAS". Represents, "Parentheses, Exponents, Multiplication, Division, Addition and subtraction".
  • User profile image
    Gabriel

    Actually, the order of operation is parentheses, then exponents, then division and multiplication, then addition and subtraction. But addition and subtraction have the same preference, so 5 - 2 + 1 = 4, not = 2; multiplication and division also have the same preference: 12 / 2 * 3 = 18, not = 2.

  • User profile image
    Kay

    For a more comprehensive explanation, see:
    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/#operator-precedence
    For operators with the same precedence, the order in which they're evaluated is dependent on whether they're left-associative or right-associative.

Add Your 2 Cents