[VPM] always floating point?

Carl B. Constantine cconstan at csc.UVic.CA
Mon Mar 31 16:44:25 CST 2003


*On Mon Mar 31, 2003 at 02:39:25PM -0800, Peter Scott (Peter at PSDT.com) wrote:
> >This is for use in the Text::Table module, so I kind of need it like
> >this or it prints .5 instead of 0.50, 0 instead of 0.00, and 0.07 as it
> >should. There is a reason for it which goes into more detail and I can
> >explain it better later, I'm just curious if I can do this or not.
> 
> printf() and sprintf() are the official answers.
> 
> [1] Okay, for the smart-alecs reading, yes, you could make $rate an 
> object and overload it's nummification op.  I hope none of you were 
> considering foisting that on poor Carl...

Actually, I don't think that would work in this case anyway.

I've taken to reworking my code a bit so the values are always floating
point. so instead of:

my $rate = 7;

I have, 

my $rate = 0.07;

and not doing the /100 later in the report. I don't think this approach
is as elegant, but I think it will work better over the long run for
this particular project.

I've asked the author of Text::Table for a few features that would make
the module more usable for financial data and a few other scenarios as
well.

-- 
Carl B. Constantine         University of Victoria
Programmer Analyst          http://www.csc.uvic.ca
UNIX System Administrator   Victoria, BC, Canada
cconstan at csc.uvic.ca        ELW A220, 721-8753



More information about the Victoria-pm mailing list