What does the *4 mean in integer*4 in fortran77?

In summary, integer*4 is a data type used in Fortran77 to represent integer numbers with a maximum size of 4 bytes or 32 bits. It is the default integer data type and is commonly used for basic arithmetic operations. It can store both positive and negative numbers, but has limitations in representing very large or small numbers.
  • #1
dimensionless
462
1
How is
Code:
integer*4
different from
Code:
integer
?
 
Technology news on Phys.org
  • #2
dimensionless said:
How is
Code:
integer*4
different from
Code:
integer
?

integer*4 is an expression where you multiply integer by 4?
 
  • #3
Integer*1 => 1 byte integer variable
Integer*2 => 2 bytes integer variable
Integer*4 => 4 bytes integer variable
Integer => 4 bytes by default but can be compiler dependent
 

FAQ: What does the *4 mean in integer*4 in fortran77?

1. What is an integer*4 in Fortran77?

Integer*4 is a data type used in Fortran77 to represent integer numbers with a maximum size of 4 bytes or 32 bits. This means that the largest integer value that can be stored in an integer*4 variable is 2^31 - 1 or 2,147,483,647.

2. How is integer*4 different from other integer data types?

In Fortran77, integer*4 is the default integer data type. This means that if a variable is not explicitly declared as a different integer data type, it will be automatically assumed to be an integer*4. Other integer data types, such as integer*2 or integer*8, have different maximum values and require more or less memory space.

3. What is the purpose of using integer*4 in Fortran77?

Integer*4 is commonly used in Fortran77 because it provides a balance between precision and memory usage. It is suitable for most basic arithmetic operations and can represent a wide range of integer values without requiring excessive memory space.

4. Can integer*4 store negative numbers?

Yes, integer*4 can store both positive and negative numbers. The first bit in an integer*4 variable is used to represent the sign (0 for positive, 1 for negative) and the remaining 31 bits are used to represent the magnitude of the number.

5. Are there any limitations to using integer*4 in Fortran77?

One limitation of using integer*4 in Fortran77 is that it cannot accurately represent numbers larger than 2,147,483,647 or smaller than -2,147,483,648. This can be an issue when dealing with very large or very small numbers in scientific or mathematical calculations. In these cases, a different data type with a larger range may be necessary.

Similar threads

Replies
14
Views
2K
Replies
1
Views
3K
Replies
20
Views
3K
Replies
5
Views
3K
Replies
12
Views
2K
Replies
4
Views
2K
Replies
2
Views
2K
Replies
47
Views
3K
Replies
27
Views
6K
Back
Top