in reply to Re^2: All Calculations Done with One Variable Give Integer Answers
in thread All Calculations Done with One Variable Give Integer Answers

That doesn't seem to be what happens here   (perl -v: 'This is perl 5, version 16, subversion 2 (v5.16.2) built for MSWin32-x86-multi-thread (with 1 registered patch....)'   whether the value of $gap is numeric or stringified:
C:\>perl -E "my $gap = 55; $gap = "$gap.00"; say $gap;" 550 C:\>perl -E "my $gap =\"55\"; $gap = "$gap.00"; say $gap;" 550

Strongly suggest you explain or correct your latest statement.

In light of marinersk's thoughtful check, remove emphasis, modify language to say:
Suggest you tell us your version of Perl (and show compact version of actual code, as suggested above).
  • Comment on Re^3: All Calculations Done with One Variable Give Integer Answers
  • Download Code

Replies are listed 'Best First'.
Re^4: All Calculations Done with One Variable Give Integer Answers
by marinersk (Priest) on Sep 23, 2013 at 18:13 UTC
    Interesting, slightly older Perl here and it does exactly what the OP indicates. Whether or not it accomplishes what he wants to accomplish is a different subject.

    I am baffled that anything would autonomously constrain itself to integer arithmetic -- I think we need to see some code to really assess what is going on.

    Update: As a complete side note, the version of Perl doesn't appear to cause a difference in the handling of the string interpretation. I suspect the difference between ww's results and mine are how we chose to display the values (either say vs. print, or command line vs. script file {perhaps the way the quotation mark characters are interpreted from the command line?} ):

    #!/usr/bin/perl -w use strict; { my $originalValue = 5; my $modifiedValue = "$originalValue.00"; my $escapedValue = "$originalValue\.00"; print "\$originalvalue = '$originalValue'\n"; print "\$modifiedvalue = '$modifiedValue'\n"; print "\$escapedvalue = '$escapedValue'\n"; } exit; __END__ ---------------[ Older Perl ]--------------- C:\Steve\Dev\PerlMonks\P-2013-09-23@1207-ForceFloat>perl -v This is perl, v5.8.9 built for MSWin32-x64-multi-thread (with 12 registered patches, see perl -V for more detail) C:\Steve\Dev\PerlMonks\P-2013-09-23@1207-ForceFloat>forcefloat.pl $originalvalue = '5' $modifiedvalue = '5.00' $escapedvalue = '5.00' ---------------[ Newer Perl ]--------------- C:\Steve\Dev\PerlMonks\P-2013-09-23@1207-ForceFloat>perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x +64-multi-thread (with 1 registered patch, see perl -V for more detail) C:\Steve\Dev\PerlMonks\P-2013-09-23@1207-ForceFloat>forcefloat.pl $originalvalue = '5' $modifiedvalue = '5.00' $escapedvalue = '5.00'
      I think I've found the culprit, but I will be providing code this evening (USA East Coast time). This is part of a big project (bookkeeping, not programming) that I'm on a deadline on. I put together a sloppy and quick test program I'll tidy up for posting here. It seems the issue is one module used Math::BigInt. I'll include new information when I add the code tonight.
        Good sleuthing -- I am highly intrigued by this so I wait with bated breath for your test sample. Wanna learn wanna learn wanna learn!
Re^4: All Calculations Done with One Variable Give Integer Answers
by Anonymous Monk on Sep 23, 2013 at 23:50 UTC

    I noticed you backslashed some of your quotes but not others. Using qq() may help:

    C:\>perl -E "my $gap = 55; $gap = qq[$gap.00]; say $gap;" 55.00