...
1e+16
1e+16
1e+16
1e+16
1e+16
1e+16
Compliant Solution
This compliant solution uses the CPAN Bignum module to ensure precise computation.
Code Block | ||||
---|---|---|---|---|
| ||||
use bignum;
my $x = 10000000000000000; # 1e+16
for (my $y = $x; $y <= $x + 5; $y += 1) {
print "$y\n";
}
|
On a 32-bit machine, this program terminates normally after printing the following:
10000000000000000
10000000000000001
10000000000000002
10000000000000003
10000000000000004
10000000000000005
Risk Assessment
Failing to understand the limitations of floating-point numbers can result in unexpected computational results and exceptional conditions, possibly resulting in a violation of data integrity.
...