sqrt.c

dw_fluffos_v1/lib/secure/simul_efun/sqrt.c · 996 B

From the archive dw_fluffos_v1.tar.gz

Download the archive   « Back to the archive contents

/*  -*- LPC -*-  */
/*
 * $Locker:  $
 * $Id: sqrt.c,v 1.3 1999/09/08 14:50:30 wodan Exp $
 * $Log: sqrt.c,v $
 * Revision 1.3  1999/09/08 14:50:30  wodan
 * changed to int version to use the float version, faster in most cases, if not all.
 *
 * Revision 1.2  1998/03/24 07:28:59  pinkfish
 * Add some docs to make the simulefuns more usefully lookupable.
 *
 * Revision 1.1  1998/01/06 05:13:15  ceres
 * Initial revision
 * 
*/
/**
 * Cotains some simul_efuns.
 * @author Pinkfish
 */
/**
 * This method attempts to find a square root of an input number.  This
 * returns a square root in the same type as the input type.
 * @see efun::sqrt()
 * @return the square root
 * @param number
 */
mixed sqrt( mixed number ) {
  if (floatp(number))
    return efun::sqrt(number);
  if (!intp(number))
    error("Bad argument 1 to sqrt()\nExpected: int or float Got: "+
          typeof(number)+ ".\n");
  if ( number < 0 )
    return -1;
  return to_int(efun::sqrt(to_float(number)));
} /* sqrt() */

Site Stats

Snippets: 1791
Codebases: 571