On Thu, 11 Jan 2001, Jarkko Hietaniemi wrote:
> > be new extracted versions of those lib files such as lib/bigint_pl.PL
> > and lib/Math/BigInt_pm.PL? That might look in part like:
> >
> > use Config;
> >
> > if ($Config{'fp_divide_broken'} eq 'define') {
> > print OUT '$prod - ($car = int($prod / 1e5)) * 1e5;';
> > }
> > else {
> > print OUT '$prod - ($car = int($prod * 1e-5)) * 1e5;';
> > }
> >
> > or somesuch?
>
> Somesuch would be nicer. And as I said, this could a BEGIN block
> decision, too.
OK the variable alluded to above would have been better name
fp_multiply_broken, but in order to be both terse and explicit how about
fp_snm_broken? As in this snippet that could fit into Configure after the
value of $i_math is determined (the eval and rm lines have been #commented
out so that I could play with this script standalone, the echo >&4 line
is commented too since I have not done the approriate exec in my login
shell):
#! /bin/sh
cat='cat'
define='define'
echo='echo'
i_math='define'
nvtype='double'
rm='rm'
undef='undef'
# note we declare variables 'double' rather than "$nvtype" since the
# latter could be 'long double' incompatible with modf()
####################################################################
: fp_snm_broken floating point small number multiplication brokeness
#$echo "Checking for floating point small number multiplication trouble..." >&4
$echo "Checking for floating point small number multiplication trouble..."
$cat > try.c <<EOCP
#include <stdio.h>
#$i_math I_MATH
#ifdef I_MATH
#include <math.h>
#endif
main() {
double rm,sm,tm;
double rd,sd,td;
double tdiff;
rm = 800000.0 * 1e-5;
tm = modf (rm,&sm);
rd = 800000.0 / 1e+5;
td = modf (rd,&sd);
tdiff = tm - td;
if (tdiff > 0.5)
printf("$define\n");
else
printf("$undef\n");
return(0);
}
EOCP
fp_snm_broken="$undef"
#if eval $compile; then
# fp_snm_broken="`./try$exe_ext`"
#fi
case "$fp_snm_broken" in
"$define") $echo "Will try to use division by large numbers instead." 2>&1
;;
"$undef") $echo "Small number multiplication looks OK." 2>&1
;;
*) $echo "Guessing that small number multiplication will work." 2>&1
fp_snm_broken="$undef"
;;
esac
#$rm -f try.* try
Peter Prymmer