Int: Difference between revisions
Mr. MacKenty (talk | contribs) (Created page with "right|frame|Programming basics<ref>http://www.flaticon.com/</ref> Int (signed integers): They are often called just integers or ints, are positive or nega...") |
|||
(6 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
[[file:arrows.png|right|frame|Programming basics<ref>http://www.flaticon.com/</ref>]] | [[file:arrows.png|right|frame|Programming basics<ref>http://www.flaticon.com/</ref>]] | ||
An int (integer) is a positive or negative whole numbers with no decimal point.<ref>https://www.tutorialspoint.com/python/python_numbers.htm</ref> | |||
== Difference between an int and a float == | == Difference between an int and a float == | ||
Line 15: | Line 15: | ||
<?php | <?php | ||
$a = 1234; // decimal number | $a = 1234; // decimal number | ||
$a = - | $a = -1234; // a negative number | ||
?> | ?> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 21: | Line 21: | ||
In Python: | In Python: | ||
<syntaxhighlight lang="python3"> | <syntaxhighlight lang="python3"> | ||
# decimal number: | |||
a = | a = 1234 | ||
# a negative number: | |||
a = -1234 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
In Javascript: | In Javascript: | ||
<syntaxhighlight lang="javascript"> | |||
// decimal number: | |||
var a = 1234; | |||
= | // a negative number: | ||
var a = -1234; | |||
</syntaxhighlight> | |||
== Standards == | == Standards == |
Latest revision as of 20:30, 5 February 2023
An int (integer) is a positive or negative whole numbers with no decimal point.[2]
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;
Standards[edit]
- Define the terms: variable, constant, operator, object.