LF Fortran 95

SCALE Function

Description

The SCALE function multiplies a REAL number by a power of two.

Syntax

SCALE (x, i)

Arguments

x is an INTENT(IN) scalar or array of type REAL.

i is an INTENT(IN) scalar or array of type INTEGER.

If both x and i are arrays, they must have the same shape.

Result

The result is the same type and kind as x. Its value is x*2i .

If either or both arguments are arrays, the result is an array of the same shape. Its values are as though the scalar SCALE operation were performed on each respective array element.

Example

real :: x.1.5,xa(2)=(/2.5,3.5/) integer :: i=3, ia(2)=(/2,4/) write(*,*) scale(x,i) ! writes 12.0 write(*,*) scale(xa,i) ! writes 20.0 28.0 write(*,*) scale(x,ia) ! writes 6.0 24.0 write(*,*) scale(xa,ia) ! writes 10.0 56.0