#
Fortran Wiki

sign

## Description

`sign(a,b)`

returns the value of `a`

with the sign of `b`

.

## Standard

FORTRAN 77 and later

## Class

Elemental function

## Syntax

`result = sign(a, b)`

## Arguments

`a`

- Shall be of type `integer`

or `real`

`b`

- Shall be of the same type and kind as `a`

## Return value

The kind of the return value is that of `a`

and `b`

. If $B\ge 0$ then the result is `abs(a)`

, else it is `-abs(a)`

.

## Example

```
program test_sign
print *, sign(-12,1)
print *, sign(-12,0)
print *, sign(-12,-1)
print *, sign(-12.,1.)
print *, sign(-12.,0.)
print *, sign(-12.,-1.)
end program test_sign
```

Revised on April 30, 2009 19:24:08
by

Jason Blevins
(71.70.142.190)
(721 characters / 0.0 pages)