[ic] [interchange-bugs] [rt.icdevgroup.org #349] Vend::Util::round_to_frac_digits() simplification

Mike Heins mike at perusion.com
Tue Mar 20 00:59:00 UTC 2012


Quoting Peter (peter at pajamian.dhs.org):
> CCing the userlist because I want Mike to see this.
> 
> On 20/03/12 04:47, Anonymous via RT wrote:
> > round_to_frac_digits()  produces ".00" when called with (0, 2).  It
> > also parses the integers incorrectly: in normal Perl "1." is a valid
> > number, as is "+3", but "-" is not valid.
> > 
> > Nearly all of the function logic can be replaced with:
> > 
> > printf "%.*f", $digist, $num;
> 
> Agreed, except it needs to be sprintf.
> 
> Mike, is there any reason to not make this change?

Absolutely. Sprintf doesn't really round.

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.253.4194  <mike at perusion.com>

Nature, to be commanded, must be obeyed. -- Francis Bacon



More information about the interchange-users mailing list