in reply to All Calculations Done with One Variable Give Integer Answers

What is $gap = "$gap.00"; supposed to do? What do you think it does? Are you using the dot to try to concat to establish a two digit decimal field (syntax is wrong) or what?

I ask because I don't see the results you seem to describe in either of these cases:

C:\>perl -E "my $gap = 1.23; $gap = $gap.00; print ($gap + 1.5);" 2.73 # not an integer C:\>perl -E "my $gap = 1; $gap = $gap.00; print ($gap + 1.5);" 11.5 # not even close! And not just BTW, WTF happens h +ere?

I think we need a very small version of your remaining code (say 20 lines or so starting with an assignment to $gap of a typical non-date, numeric value) to know what's going on.

If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.

Replies are listed 'Best First'.
Re^2: All Calculations Done with One Variable Give Integer Answers
by HalNineThousand (Beadle) on Sep 23, 2013 at 17:50 UTC
    If $gap was previously equal to, say, 55, and I use $gap = "$gap.00" and print the result, I get 55.00. I guess I could use $gap = $gap."00" or other versions, but I tried this version and once I did that, from then on, any math done with $gap was no longer yielding integer results.
      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).
        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 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