int
type represents an integer, a positive or negative whole number. You use the +
symbol for addition. Other common mathematical operations for integers include:-
for subtraction*
for multiplication/
for division%
character:int
type has minimum and maximum limits. Run this codein the interactive window to see those limits:min + 2
.The addition operation overflowed the allowed values for integers.The answer is a very large negative number because an overflow 'wraps around'from the largest possible integer value to the smallest.int
type doesn't meet your needs. Let's explore those next.double
numeric type represents a double-precision floating pointnumber. Those terms may be new to you. A floating point number isuseful to represent non-integral numbers that may be very large or smallin magnitude. Double-precision means that these numbers are storedusing greater precision than single-precision. On modern computers,it is more common to use double precision than single precision numbers.Let's explore. Try the following code in the interactive window and see the result:E
is the significand. The number to the right is the exponent,as a power of 10.0.3
repeating is not exactly the same as 1/3
.double
type. Try more complicated calculations.decimal
type. The decimal
type has a smallerrange but greater precision than double
. The term fixed point meansthat the decimal point (or binary point) doesn't move. Let's take a look:double
type. You can see the greaterprecision with the decimal type by trying the following code:M
suffix on the numbers is how you indicate that a constant should use thedecimal
type.