in reply to Re^3: All Calculations Done with One Variable Give Integer Answers
in thread All Calculations Done with One Variable Give Integer Answers
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'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: All Calculations Done with One Variable Give Integer Answers
by HalNineThousand (Beadle) on Sep 23, 2013 at 23:27 UTC | |
by marinersk (Priest) on Sep 23, 2013 at 23:42 UTC | |
by syphilis (Archbishop) on Sep 24, 2013 at 00:08 UTC | |
by HalNineThousand (Beadle) on Sep 24, 2013 at 04:27 UTC | |
by HalNineThousand (Beadle) on Sep 24, 2013 at 04:24 UTC | |
by syphilis (Archbishop) on Sep 24, 2013 at 04:57 UTC | |
by HalNineThousand (Beadle) on Sep 24, 2013 at 06:12 UTC | |
|