Try to provide a more realistic, and complete example of your problem, keeping the code to a minimum to reproduce the behavior you're seeing. Your current example does not output anything useful for me, only the output headers (no actual values, besides "Post" values of 0 0.) This makes your problem impossible to diagnose without more relevant information.
Further, the example provided should almost always enable the use strict and use warnings pragmas. I get no fewer than 27 compilation errors using strict in your example; you should review these and in most cases correct them before requesting help as the compiler catches many possible mistakes for you.
Multiplying and adding works as described in perlop for me. Given how you reference variables you never describe in the example, it's almost surely caused by code not shown.
use strict; use warnings; my $factor = 0.5; my $base = -15; my $base2 = -8; result( "$base * $factor", $base * $factor ); result( "$base2 + $base * $factor", $base2 + $base * $factor ); # Show a result. # Pass it 2 args: # ARG1: display string to inform user about the calculation. # ARG2: displayed as a float, 2 place precision. sub result { printf "%s is: %.2f\n", shift // '', shift // 0; }
In reply to Re: Floating point hell
by Apero
in thread Floating point hell
by DcmbrAgnt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |