RWalib C Array Library User Guide > Rounding Operations > alibFloor
  

alibFloor
Applies the floor function to each element of an array. The PV-WAVE API for this routine is the GREAT_INT Function.
Prototypes
void alibFloorf( wvlong n, float *p, float *r )
void alibFloord( wvlong n, double *p, double *r )
Parameters
n — (Input) The number of elements in the array.
*p — (Input) The n-element source array.
*r — (Input/Output) The destination array. On return, r[i] = floor(p[i]). This operation can be done in-place, i.e., r can equal p.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
   /* make up some data for the examples */
   float  f0[5]={0.25,1.5,2.75,3,4.75}, *f;
   /* make output array */
   f = (float*)malloc(5*sizeof(float));
   printf( "\n\n show array f0" );
      alibinit( NULL, NULL, NULL, NULL );
      alibPrintArrayf( 1, 1, 1, 5, f0, NULL );
   printf( "\n\n show the floor of each element in f0" );
      alibFloorf( 5, f0, f );
      alibPrintArrayf( 1, 1, 1, 5, f, NULL );
}
 
Output:
 
 show array f0
 
   2.500e-01   1.500e+00   2.750e+00   3.000e+00   4.750e+00
 
 show the floor of each element in f0
 
   0.000e+00   1.000e+00   2.000e+00   3.000e+00   4.000e+00

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.