Int

From Computer Science Wiki
Revision as of 10:56, 20 June 2019 by Mr. MacKenty (talk | contribs)
Programming basics[1]

An int (integer) is a positive or negative whole numbers with no decimal point.[2]

Signed and unsigned[edit]

There is a deeper conversation about signed and unsigned numbers. You should know this:

  • A signed number can be positive or negative
  • An unsigned number can only be positive

Difference between an int and a float[edit]

Integers and floats are two different kinds of numerical data. An integer (more commonly called an int) is a number without a decimal point. A float is a floating-point number, which means it is a number that has a decimal place. Floats are used when more precision is needed.[3]

Example[edit]

In PHP: You will remember PHP isn't a strictly typed language (although it can be set to be).

<?php
$a = 1234; // decimal number
$a = -1234; // a negative number
?>

In Python:

# decimal number:
a = 1234
# a negative number:
a = -1234

In Javascript:

// decimal number:
var a = 1234; 
// a negative number:
var a = -1234;

Do you understand this?[edit]

Standards[edit]

  • Define the terms: variable, constant, operator, object.

References[edit]