Everything2
Near Matches
Ignore Exact
Full Text
Everything2

int

created by Falrick

(idea) by si1k (6 y) (print)   ?   (I like it!) Sat Nov 13 1999 at 9:06:10

1. The command from the x86 instruction set that calls a software interrupt, for example INT 21H to call a DOS function. 2. A keyword used in C, C++ and other languages to declare or indicate an integer type. It is supposed to be of the word size of the machine, so that instructions on it will be faster. Can be signed, unsigned. Two other integer types are char and long.

(thing) by Wicker808 (1.9 y) (print)   ?   (I like it!) Mon Jul 30 2001 at 17:24:52

int is a type used in many C-like languages, including C itself, C++, Objective C, Inform, Java, and C#. It indicates an integer type, which is to say a whole number. The upper and lower bounds of values able to be stored as int vary depending on the language, platform, and, if applicable, modifiers used.

For any given compiler and platform combination, it is usually a valid assumption that a natural int is the same size as the word size of that architecture, which may or may not be the same size as pointers. However, for portability reasons, it is strongly deprecated to ever code to utilise these assumptions.

In most languages, int is a built-in, or atomic type. It is also usually a keyword.


The following comments refer specifically to the C language, and extensions thereto such as C++.

Under C, int is the default type. This mean that if a type is omitted where one is required, it is assumed to be int. For that reason, the following three declarations are valid (taken out of context, naturally):

auto count;
static g_CharBroiled=0;
size(struct MAP *map) { return map->size; }

Note than in the variable declarations above, if the type is omitted, a storage class is still required so that the compiler recognizes the line as a declaration rather than a reference to an existing name. Declaration by omission of type name is deprecated under C++.

C supports four modifiers to the int type: signed, unsigned, short, and long. signed is mutually exclusive to unsigned, as short is to long. These modifiers can be used to prefix the int keyword, or without the int keyword in which case it is implicit.

If unsigned is not specified, the type is a signed type, meaning that both negative and non-negative numbers are within the range of the type. unsigned types only hold non-negative values. A signed int of the same size as an unsigned int will usually have an upper bound of half the upper bound of the unsigned, and its lower bound will be compensatorially lower. I have no idea if compensatorially is really a word.

The short and long modifiers affect the size, which is say memory and therefore upper and lower bounds, of the type. short and long ints may or may not be the same size as a so-called "natural" int, or int with no size modifier.

Specifically, regarding these modifiers, the ANSI C standard requires that:

sizeof(short int) <= sizeof(int) <= sizeof(long int)

It is a limitation of the C language that there are a maximum of three non-char sizes of integers available. This can be problematic with the onset of 64-bit architectures for compilers that wish to support very large integers without changing the meaning of existing pointer sizes and thereby break code.

So, various compilers have various ways of getting around this limitation, with varying degress of ugliness. Some implementations support an __int64 extension and some brain-damanged implementations support the very non-ANSI-compliant long long notation.


In the Java language, int is still a built-in keyword type, but it does not support any modifiers. Instead, short and long are types independently, and all three are signed in all cases. The Java platform specification indicates specific sizes for the int, short, and long types, being 32-bit, 16-bit, and 64-bit respectively.



In addition to its meaning as a type symbol in several languages, INT is also the Interrupt mnemonic in x86 assembly language, corresponding to opcode CD and taking an immediate 8-bit argument. INT is a priveleged instruction and only has its described function in kernel or driver (which is to say, ring 0 and ring 1) code or in real mode. Application code executing an INT should be abnormally terminated.

INT will invoke the interrupt handler indicated by its argument. In real mode, this means, given argument immed8, it will push onto the stack (E)FLAGS and CS:(E)IP and jump to the address stored at (4*immed8), segment 0. In protected mode, the location of the interrupt vector table can be changed, and in the fact the vectors themselves may be in the form selector:offset rather than segment:offset, or may indicate a physical address, depending on the OS. I frankly don't recall, but I recommend Intel's Technical Reference Manual on the subject for those interested in Protected Mode arcana.

INT 3 is a special exception that has a one-byte representation of CC. This opcode is used by cheesy real-mode debuggers to place breakpoints in client code. The two-byte opcode CD 03 is equivelent.

See also the related x86 mnemonic INTO (Interrupt on Overflow).


printable version
chaos

fifty ways to hose your code long Object Orientation in ANSI C C conversion types
Base minus 2 solution integer One character error Essential C Functions
typedef The Dr Strangelove syndrome stdio.h javax.swing.JTable
C++: Checking units at compile time offsetof fsync VBA/DAO3.5: RollDice()
stdlib.h .int Short Java Developer Connection
int32 void Wis for(int *p=0;;*(p++)=0);
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Look at this mess the Death Borg made!
Villages in Germany are three kilotons apart
The world breaks everyone
Antietam
Attention
torque
Dover test
Some people break so easily
Giving Your Cat a Pill (and your little dog, too!)
Quantum Quake
Egg Drop
Pithing the frog
Danse Macabre
Kit Kat Konspiracy
New Writeups
Alnilamski
Rebel Yell(thing)
Heisenberg
Dahon Speed D7(thing)
etgar
Protection of civil rights in the USA and UK(essay)
archiewood
Airspace classifications(idea)
Ouzo
My first Christmas(event)
TheDeadGuy
Editor Log: August 2008(log)
AspieDad
Tools of the Trade(essay)
Apatrix
Editor Log: August 2008(log)
etouffee
Back where we started(poetry)
NeverLost
I'm never getting drunk again(idea)
Noung
post-racial(idea)
Heitah
Intensive farming(essay)
XWiz
Big Science(review)
Wuukiee
yellow cake batter(recipe)
Pavlovna
Sassenach(person)
This page courtesy of The Everything Development Company