in reply to subtraction issue

This should result in $finalamount = 0

If you printf "%a\n", $v_amount; and printf "%a\n", $plbamount; (for which you need to be running perl-5.22.0 or later) you'll get to see the exact value of the 2 variables (in hex).

If they turn out to be the same && $finalamount is not zero, then you have a seriously broken perl.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: subtraction issue
by AnomalousMonk (Archbishop) on Jan 24, 2017 at 22:59 UTC

    Anonymous: Previous to Perl version 5.22.0, you can use a format like '%0.20f'.


    Give a man a fish:  <%-{-{-{-<

      Previous to Perl version 5.22.0, you can use a format like '%0.20f'

      Yes, I think that's a good enough replacement for most purposes - and a useful addition to my post.

      However, it's not guaranteed to give you the exact base 10 value stored in the double - whereas %a will give you the exact (base 16) value.

      Cheers,
      Rob

        Feel free to ignore this post. I just couldn't help myself (I needed the coffee-break distraction, apparently)