[comp.sys.amiga.tech] Help needed from UNIX buff

BAXTER_A@wehi.dn.mu.oz (08/07/90)

I am currently porting (I hope) HPGLtoPS and was wondering:

What does the UNIX C function rint() do?

Email would be nice,
Regards Alan

spoffojj@hq.af.mil (Jason Spofford) (08/07/90)

In <10936@wehi.dn.mu.oz> BAXTER_A@wehi.dn.mu.oz writes:
>I am currently porting (I hope) HPGLtoPS and was wondering:

>What does the UNIX C function rint() do?

Here is the man page on rint() - I couldn't mail directly so everyone
else may want to skip the rest of this mail note.

RINT(3M)              MATHEMATICAL LIBRARY               RINT(3M)

NAME
     aint, anint, ceil, floor,  rint,  irint,  nint  -  round  to
     integral value in floating-point or integer format

SYNOPSIS
     #include <math.h>

     double aint(x)
     double x;

     double anint(x)
     double x;

     double ceil(x)
     double x;

     double floor(x)
     double x;

     double rint(x)
     double x;

     int irint(x)
     double x;

     int nint(x)
     double x;

DESCRIPTION
     aint, anint, ceil, floor, and rint() convert a double  value
     into  an  integral value in double format.  They vary in how
     they choose the result when the argument is not  already  an
     integral  value.   Here an integral value means a value of a
     mathematical integer, which however might be  too  large  to
     fit in a particular computer's int format.  All sufficiently
     large values  in  a  particular  floating-point  format  are
     already  integral;  in  IEEE  double-precision  format, that
     means all values >= 2**52.   Zeros,  infinities,  and  quiet
     NaNs  are  treated  as  integral  values by these functions,
     which always preserve their argument's sign.

     aint() returns the integral value between _x and  0,  nearest
     _x.  This corresponds to IEEE rounding toward zero and to the
     Fortran generic intrinsic function aint.

     anint() returns the nearest  integral  value  to  _x,  except
     halfway  cases  are  rounded to the integral value larger in
     magnitude.  This corresponds to the Fortran generic  intrin-
     sic function anint.

     ceil() returns the least  integral  value  greater  than  or
     equal  to  _x.   This  corresponds  to  IEEE  rounding toward

Sun Release 4.0   Last change: 15 October 1987                  1

RINT(3M)              MATHEMATICAL LIBRARY               RINT(3M)

     positive infinity.

     floor() returns the greatest integral  value  less  than  or
     equal  to _x.  This corresponds to IEEE rounding toward nega-
     tive infinity.

     rint() rounds _x  to  an  integral  value  according  to  the
     current IEEE rounding direction.

     irint converts _x into int format according  to  the  current
     IEEE rounding direction.

     nint() converts _x into int format rounding  to  the  nearest
     int value, except halfway cases are rounded to the int value
     larger in magnitude.  This corresponds to the  Fortran  gen-
     eric intrinsic function nint.

Sun Release 4.0   Last change: 15 October 1987                  2




--
----------------------------------------------------------
)   Jason Spofford        The LAN Manager                (
)   spoffojj.hq.af.mil    George Mason Univ. Grad. Stud. (
----------------------------------------------------------

aduncan@rhea.trl.oz.au (Allan Duncan) (08/09/90)

From article <10936@wehi.dn.mu.oz>, by BAXTER_A@wehi.dn.mu.oz:
> I am currently porting (I hope) HPGLtoPS and was wondering:
> 
> What does the UNIX C function rint() do?
> 
> Email would be nice,
> Regards Alan
Allan Duncan	ACSnet	a.duncan@trl.oz
(03) 541 6708	ARPA	a.duncan%trl.oz.au@uunet.uu.net
		UUCP	{uunet,hplabs,ukc}!munnari!trl.oz.au!a.duncan
Telecom Research Labs, PO Box 249, Clayton, Victoria, 3168, Australia.

aduncan@rhea.trl.oz.au (Allan Duncan) (08/09/90)

From article <10936@wehi.dn.mu.oz>, by BAXTER_A@wehi.dn.mu.oz:
> I am currently porting (I hope) HPGLtoPS and was wondering:
> 
> What does the UNIX C function rint() do?

[Sorry about the previous dud followup.]

It stands for round integer -

double rint(x)
double x

returns the integer represented as a double nearest to x in the
prevailing mode.

It doesn't appear in V7 Unix, but it is in Ultrix, find it under the
entry for floor().
Allan Duncan	ACSnet	a.duncan@trl.oz
(03) 541 6708	ARPA	a.duncan%trl.oz.au@uunet.uu.net
		UUCP	{uunet,hplabs,ukc}!munnari!trl.oz.au!a.duncan
Telecom Research Labs, PO Box 249, Clayton, Victoria, 3168, Australia.

david@twg.com (David S. Herron) (08/11/90)

In article <10936@wehi.dn.mu.oz> BAXTER_A@wehi.dn.mu.oz writes:
>I am currently porting (I hope) HPGLtoPS and was wondering:
>
>What does the UNIX C function rint() do?
>
>Email would be nice,
>Regards Alan

Will a Unix beige do instead??

er..

Anyway, I'd never heard of this routine before so I looked it up.
It's a new one to the man page I found it on, so it must be pretty recent.
Quoting from the SunOS man page:

...
	double rint(x)
	double x;
...
	rint() rounds {\it {\bf x}} to an integral value according to
	the current IEEE rounding direction.

There is an ieee_flags() routine which lets you set various IEEE floating
point options.  For instance, 

	ieee_flags("set", "direction", "tozero", &out);

will set the rounding direction towards zero.

Weeeeiiirrrdd..  (useful though..)
-- 
<- David Herron, an MMDF weenie, <david@twg.com>
<- Formerly: David Herron -- NonResident E-Mail Hack <david@ms.uky.edu>
<-
<- Sign me up for one "I survived Jaka's Story" T-shirt!