#!/usr/bin/perl use warnings; use strict; use Inline C => <<'END_C'; #include int _getround() { return fegetround(); } int _setround(int mode) { return fesetround(mode); } int _round_down() { return fesetround(FE_DOWNWARD); } END_C ## simulate my object my $one = 1.0; my $three = 3.0; ## save the rounding mode and set to round towards negative infinity my $mode = _getround(); my $changed = _round_down(); ## perform the calculations my $lb = $one / $three; my $ub = -( -$one / $three ); ## restore the original rounding mode to be nice _setround($mode); ## display the results printf( "\$lb = %.23f\n", $lb ); printf( "\$ub = %.23f\n", $ub ); print "\$lb == \$ub ", $lb == $ub ? 'true' : 'false', "\n"; print "\$changed = $changed\n"; #### P:\>fround $mode = 0 $lb = 0.33333333333333331000000 $ub = 0.33333333333333337000000 $lb == $ub false $changed = 0