in reply to Getting different results with $var++ and $var += 1
Hello,
The way you "force (a scalar) to float context" in perl is simply use it in numeric context (construct an expression that would require the scalar be used as a number). So the += 0 stuff isn't necessary.
Anywhoo, what you are trying to do works fine in general so you have something funky going on in your code, and you haven't given us enough information to suggest a solution:
$ perl use warnings; use strict; my $retail_rate = 109.98; my $coupon = 10.05; my $discounted_rate = $retail_rate + 1; print "$retail_rate $coupon $discounted_rate\n"; Ctrl-D 109.98 10.05 110.98
Hope this helps,
trwww
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting different results with $var++ and $var += 1
by splicer (Novice) on Dec 03, 2008 at 20:33 UTC | |
by ikegami (Patriarch) on Dec 03, 2008 at 21:46 UTC | |
by GrandFather (Saint) on Dec 03, 2008 at 21:25 UTC | |
by splicer (Novice) on Dec 03, 2008 at 22:05 UTC | |
by syphilis (Archbishop) on Dec 03, 2008 at 23:29 UTC | |
by splicer (Novice) on Dec 04, 2008 at 00:23 UTC | |
|