LF Fortran 95

SCALE Function


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


SCALE (x, i)


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.


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.


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