[svn:parrot] r46714 - trunk/src/ops

Andy Dougherty doughera at lafayette.edu
Mon May 17 12:56:15 UTC 2010


On Sun, 16 May 2010, Nicholas Clark wrote:

> On Sun, May 16, 2010 at 05:32:41PM +0000, plobsing at svn.parrot.org wrote:
> > Author: plobsing
> > Date: Sun May 16 17:32:40 2010
> > New Revision: 46714
> > URL: https://trac.parrot.org/parrot/changeset/46714
> > 
> > Log:
> > use abs/fabs in stead of roll-your-own abs
> > 
> > Modified:
> >    trunk/src/ops/math.ops
> > 
> > Modified: trunk/src/ops/math.ops
> > ==============================================================================
> > --- trunk/src/ops/math.ops	Sun May 16 17:09:57 2010	(r46713)
> > +++ trunk/src/ops/math.ops	Sun May 16 17:32:40 2010	(r46714)
> > @@ -52,17 +52,11 @@
> >  }
> >  
> >  inline op abs(out INT, in INT) :base_core {
> > -    if ($2 < 0)
> > -        $1 = - (INTVAL)$2;
> > -    else
> > -        $1 = (INTVAL)$2;
> > +    $1 = abs($2);
> 
> Can sizeof(INT) be greater than sizeof(int) ?

Yes, easily.  In fact, that is the default behavior default behavior on 
any system where sizeof(long) > sizeof(int).

> >  inline op abs(out NUM, in NUM) :base_core {
> > -    if ($2 < 0)
> > -        $1 = - (FLOATVAL)$2;
> > -    else
> > -        $1 = (FLOATVAL)$2;
> > +    $1 = fabs($2);
> 
> Likewise, can sizeof(FLOATVAL) be greater than sizeof(double) ?

Yes, though I think that requires a Configure.pl option 
(such as --floatval='long double') to be activated.

-- 
    Andy Dougherty		doughera at lafayette.edu


More information about the parrot-dev mailing list