Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
xt_double_cmp(3)	    Library Functions Manual		xt_double_cmp(3)

NAME
     xt_double_cmp() - Compare two doubles for qsort(3), bsearch(3), etc.

LIBRARY
     #include <xtend/math.h>
     -lxtend

SYNOPSIS
     int     xt_double_cmp(const double *n1, const double *n2)

ARGUMENTS
     n1, n2  Pointers to two double values

DESCRIPTION
     This  is  a  function that compares two doubles as a service to polymorphic
     functions such as	qsort(3),  bsearch(3),	etc.   The  address  of  xt_dou-
     ble_cmp()	is  passed as an argument to perform the data type specific com-
     parison on behalf of the sort of search function.

RETURN VALUES
     A value > 0 if *n1 is greater than *n2 A value < 0 if *n1 is less than  *n2
     0 if the values are equal

EXAMPLES
     double  list[LIST_SIZE];

     // sizeof(*list) will continue to work if we change the data type
     // We'll still need to change the cmp function, though
     qsort(list, LIST_SIZE, sizeof(*list),
	   (int (*)(const void *, const void *))xt_double_cmp);

SEE ALSO
     qsort(3), heapsort(3), mergesort(3), bsearch(3)

								xt_double_cmp(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=xt_double_cmp&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help