On Tue, Apr 27, 2010 at 9:16 AM, Uri Guttman <u...@stemsystems.com> wrote:

> >>>>> "RC" == Rob Coops <rco...@gmail.com> writes:
>
>  RC> @Uri, returning 0 or 0.00 does make a small difference in that the
>  RC> receiving program likes the 0.00 better then the plain 0 don't ask
>  RC> me why ask our mainframe colleagues why. I wish I could let perl
>  RC> do the work for me but it simply does not regardless of how I try
>  RC> and do it return the "right" numbers when I compare them with the
>  RC> numbers in the Uniface system. I have a sample set of a month
>  RC> worth of invoices for 1 country and the below code is the only way
>  RC> in which I was able to emulate the behaviour of the Uniface system
>  RC> in all cases. My feeling is that the Uniface system does the same
>  RC> kind of weird trick.
>
> from perl's perspective 0 and 0.0 are the same as long as you deal with
> numbers.
>
> perl -le '$x = 0 ; print $x ; $x = 0.00 ; print $x'
> 0
> 0
>
> so you can't tell the difference without getting into the guts with xs
> or some special code. you mention a receiving program which may make a
> difference but again perl won't know or care. there may be more code
> than you are showing which makes a difference between the two but basic
> perl doesn't know or care.
>
> uri
>
> --
> Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com--
> -----  Perl Code Review , Architecture, Development, Training, Support
> ------
> ---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com---------
>

I completely agree perl couldn't care less if you return 0 or 0.00 it will
simply interpet it as a 0, but the recieving mainframe system gets all warm
and fuzzy when you send it 0.00 and a bit unhappy when it recieves a lone 0.
Since the whole point of the round routine is to return a whole number with
two digits behind the dot I figured it would be better to have it always
return just that even if the total value ends up being 0. It saves me from
having to format the values later on as i am now 100% certain that i will
always recieve a hole number with two digits after the dot.
*(And that, boys and girls is why adding comments to your code is a good
idea it helps explain these kinds of things) :D*
Sorry for that I should have at least explained that a bit better in a
simple comment behind te return or something along those lines.

Reply via email to