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'

In reply to Re^4: All Calculations Done with One Variable Give Integer Answers by marinersk
in thread All Calculations Done with One Variable Give Integer Answers by HalNineThousand

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.