Variables that are integers can have the values 0,1,2,3,4, ... That is, integers are the counting numbers. They cannot have fractional values such as 0.666666 or 3.1415... Integers can also have negative values if they are "signed", which is usually the default.
//C++ code example follows:
//Declare two integers and print their values.
#include
using namespace std;
int main(void){
int a = 3;
int b = -16;
cout << "a is an integer with value " << a << endl;
cout << "b is an integer with value " << b << endl;
return 0;
}
2006-09-10 13:14:38
·
answer #1
·
answered by tarahloft 2
·
0⤊
0⤋
It's true that the int type represents only numbers with no fractional part. However, the range of an int is typically -2.1 billion to +2.1 billion. Posters who said something about 32767 or 65536 are thinking of 16 bit integers (aka short), but the int type is just about always 32 bits.
As an example, consider this code:
int x = 5/3;
both 5 and 3 are integers, so "integer division" is performed. This means that the fractional part of the result is discarded. So, even though 5/3 should be 1.66666, the variable x will be set to 1. The .6666 got thrown away.
2006-09-10 22:30:35
·
answer #2
·
answered by arbeit 4
·
0⤊
0⤋
In C (it is the same in C++) an integer (noted int) is variable that
store a number with no decimal part
example:
int x=42;
The problem is that "C" does NOT define what is the largest number you can put in an "int" variable. This is computer dependent
On most 16bits computers you can put any number between 32767 and -32768
On 32bits computers (the most common computers today) the limit are extended to
2 147 483 647 ... -2 147 483 648
Additional note
==========
"C" also supports "unsigned int" that can only store positive numbers (they reuse the negative values to store larger positive numbers
On a 16bits an "unsigned int" can store any number between 0 and 65535.
On a 32 bits computer an "unsigned int" can store any number between 0 and
4 294 967 295 (i.e. more than 4 Billion !)
2006-09-11 16:35:20
·
answer #3
·
answered by cd4017 4
·
0⤊
0⤋
In a computer language, an integer is a value representable by a register inside the CPU chip. If a CPU chip is "32 bit" that means that the integer is 32 bits, which means you can represent positive numbers 0 to 2^32 power.
Within the C++ programming language, you use the "int" type to represent a number in that range, so for example:
int num = 255252599
Floats are used to store numbers with decimals in it, like 3.14
2006-09-11 01:01:09
·
answer #4
·
answered by soulblazer28 2
·
0⤊
0⤋
Any whole number.
In most programming languages several types of integer variable can be declared, the differences being (a) the range of numbers, and (b) whether negative numbers are allowed to be stored in the variable. The keywords used to declare these types of integer vary from language to language.
2006-09-11 08:50:05
·
answer #5
·
answered by Mr DJ 2
·
0⤊
0⤋
integer is a whole number, typically in programming a variable of type integer can be any whole number between -65,535 and +65,536. Well, this is as I recall off the top of my head. It's been about 5 yrs since I studied C++.
2006-09-10 20:00:52
·
answer #6
·
answered by I ♥ AUG 6
·
1⤊
0⤋
In maths, u know integer means: .....,-3,-2,-1,0,1,2,3,......... etc. OK? Now here some rules 4 constructing integer constants :
1) It must hv at least 1 digit
2) It must not hv a decimal point
3) It can b either +ve or -ve
4) If no sign precedes int, it's assumed 2 b +ve
5) Allowable range 4 int constants is -32768 to 32767 (in case of 16-bit compiler).
Now if u use int(5/3) it will give result=1, bcoz... float(5/3)=1.666667 , when it gets converted into int it'll consider only the digits b4 the decimal point.
Hope I've helped u.
2006-09-10 23:42:33
·
answer #7
·
answered by Innocence Redefined 5
·
0⤊
1⤋
An integer (in computing) refers to a datatype that equates to a whole or natural number and can be positive, negative or zero. An "int" datatype in C/C++ is a subset ranging from -65,535, through 0 and on to +65,536.
2006-09-10 20:12:45
·
answer #8
·
answered by blank 3
·
0⤊
0⤋
Integer = variable that holds whole numbers.
2006-09-11 17:25:39
·
answer #9
·
answered by Siu02rk 3
·
0⤊
0⤋
If you declare a number as being an integer.....For example if you want to display 3.566 as an integer (Cint) will covert it to a whole number eg :
<%
response.write Cint("3.566")
%>
It will show '4' on the screen.
2006-09-11 06:18:43
·
answer #10
·
answered by Captainbakslap 1
·
0⤊
0⤋