Manual Reference Pages  - aint (3fortran)

NAME

AINT(3) - [NUMERIC] Truncate toward zero to a whole number

SYNOPSIS

result = aint(x [,kind])

         elemental real(kind=KIND) function iaint(x,KIND)

real(kind=**),intent(in) :: x integer(kind=**),intent(in),optional :: KIND

CHARACTERISTICS

o a kind designated as ** may be any supported kind for the type
o the result is a real of the default kind unless KIND is specified.
o KIND is an integer initialization expression indicating the kind parameter of the result.

DESCRIPTION

AINT(3) truncates its argument toward zero to a whole number.

OPTIONS

o X : the real value to truncate.
o KIND : indicates the kind parameter of the result.

RESULT

The sign is the same as the sign of X unless the magnitude of X is less than one, in which case zero is returned.

Otherwise AINT(3) returns the largest whole number that does not exceed the magnitude of X with the same sign as the input.

That is, it truncates the value towards zero.

EXAMPLES

Sample program:

    program demo_aint
    use, intrinsic :: iso_fortran_env, only : sp=>real32, dp=>real64
    implicit none
    real(kind=dp) :: x8
       print *,’basics:’
       print *,’ just chops off the fractional part’
       print *,  aint(-2.999), aint(-2.1111)
       print *,’ if |x| < 1 a positive zero is returned’
       print *,  aint(-0.999), aint( 0.9999)
       print *,’ input may be of any real kind’
       x8 = 4.3210_dp
       print *, aint(-x8), aint(x8)
       print *,’elemental:’
       print *,aint([ &
        &  -2.7,  -2.5, -2.2, -2.0, -1.5, -1.0, -0.5, &
        &  0.0,   &
        &  +0.5,  +1.0, +1.5, +2.0, +2.2, +2.5, +2.7  ])
    end program demo_aint

Results:

     basics:
      just chops off the fractional part
      -2.000000      -2.000000
      if |x| < 1 a positive zero is returned
      0.0000000E+00  0.0000000E+00
      input may be of any real kind
      -4.00000000000000        4.00000000000000
     elemental:
      -2.000000      -2.000000      -2.000000      -2.000000      -1.000000
      -1.000000      0.0000000E+00  0.0000000E+00  0.0000000E+00   1.000000
       1.000000       2.000000       2.000000       2.000000       2.000000

STANDARD

FORTRAN 77

SEE ALSO

ANINT(3), INT(3), NINT(3), SELECTED_INT_KIND(3), CEILING(3), FLOOR(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 aint (3fortran) April 28, 2024
Generated by manServer 1.08 from 539ac798-350b-4880-bb5a-326e49fd9fd6 using man macros.