Re: RLIB 1.3.3: function abs() works only for integers

Bob Doan <bdoan-J0aWFLYJOWhWk0Htik3J/[email protected]> Thu, 12 May 2005 16:06:56 -0400
Newsgroups gmane.text.rlib.user
Message-ID <1115928416.14510.18.camel@term001>
Derek,

Are you sure?

Try: 

<field format="'%.5d'" value="abs(-5.3333)" width="10"/>

It works for me.

Also RLIB doesn't need to call fabs because the number is stored in FXP
and not floating point notation for numerical accuracy

- bob


On Thu, 2005-05-12 at 13:34 -0500, Derek Giromini wrote:
> RLIB Gurus--
> 
> The RLIB function abs() works only for integers, which explains why
> float values passed to this function break in our reports. I refer you
> to pcode_op_functions.c lines 688 through 701:
> 
> gint rlib_pcode_operator_abs(rlib *r, struct rlib_value_stack *vs,
> struct rlib_value *this_field_value) { 
>     689         struct rlib_value *v1, rval_rtn; 
>     690         v1 = rlib_value_stack_pop(vs); 
>     691         if(RLIB_VALUE_IS_NUMBER(v1)) { 
>     692                 gint64 result =
> abs(RLIB_VALUE_GET_AS_NUMBER(v1)); 
>     693                 rlib_value_free(v1); 
>     694                 rlib_value_stack_push(vs,
> rlib_value_new_number(&rval_rtn, result)); 
>     695                 return TRUE; 
>     696         } 
>     697         rlib_pcode_operator_fatal_execption("abs", 1, v1,
> NULL, NULL); 
>     698         rlib_value_free(v1); 
>     699         rlib_value_stack_push(vs,
> rlib_value_new_error(&rval_rtn)); 
>     700         return FALSE; 
>     701 }
> 
> It calls only the standard abs() function and doesn't attempt to check
> if the number is a double so that it could instead call the standard
> fabs() function.
> 
> I could take a crack at fixing this if you'd prefer, but I wanted to
> bring it to your attention.
> 
> Cheers
> 
> -- 
> Derek Giromini 
> Gelber Group, L.L.C. 
> desk: +1.312.692.2843 
> pager: +1.312.689.0378
> 



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click