in reply to Float values from MS SQL Server.

Hmmmm:
perl -we '$a="2.12121231E-4"; print $a+0,"\n";' 0.000212121231
Methinks it is already recognised as a number. Note the lack of any warning, and the fact that the result is correct...

Replies are listed 'Best First'.
Re: Re: Float values from MS SQL Server.
by Win (Novice) on Mar 04, 2004 at 10:05 UTC
    I think that the problem is that my calculation is having to work with the mumber 422420.0 . The MS SQL Server doesn't hold it like this. Why should the Perl scipt pick it up in this format? I get these kind of messages:
    Use of uninitialized value in subtraction (-) at Creating_table_ZZI_Pa +ul.pl line 1210. Use of uninitialized value in subtraction (-) at Creating_table_ZZI_Pa +ul.pl line 1210. Use of uninitialized value in multiplication (*) at Creating_table_ZZI +_Paul.pl l ine 1211. Use of uninitialized value in addition (+) at Creating_table_ZZI_Paul. +pl line 12 16. Use of uninitialized value in subtraction (-) at Creating_table_ZZI_Pa +ul.pl line 1217. Use of uninitialized value in subtraction (-) at Creating_table_ZZI_Pa +ul.pl line 1217. Invalid n: 0
      I have converted the 422420.0 value to an INT and removed the problem of '422420.0'. But the error messages stay the same. So I guess Perl can handle '422420.0' without any problems. There must be a problem with the equations. The equations take the form:
      my $numerator_L = 2*($SUM_ni-$SUM_xi); + my $denominator_L = 2*$SUM_xi; + my $numerator_U = 2*($SUM_xi+2); + my $denominator_U = 2*($SUM_ni-$SUM_xi);
        Can you print $SUM_ni and $SUM_xi just before that equation? Never mind what you think is in there, let's see what is realy in there.

        Then we can determine if the actual problem is realy the format of the numbers or something else...

        In summary. This bit of code gives:
        while ( my @col_col = $sthZK_Update_extract->fetchrow() ) { my $Key_m = $col_col[0]; my $Cause = $col_col[1]; my $Aggregated_area = $col_col[2]; my $SUM_wixi = $col_col[3]; my $SUM_wi = $col_col[4]; my $SUM_xi = $col_col[5]; my $SUM_ni = $col_col[6]; my $Sum_wi2xi = $col_col[7]; print "\n^^^^^^\n$Key_m, $Aggregated_area, $Cause, $SUM_wixi, $S +UM_wi, $SUM_xi, $SUM_ni, $Sum_wi2xi\n"; } my $numerator_L = 2*($SUM_ni-$SUM_xi); my $denominator_L = 2*$SUM_xi; my $numerator_U = 2*($SUM_xi+2); my $denominator_U = 2*($SUM_ni-$SUM_xi);
        Gives:
        ^^^^^^ 1, All, Circulatory_Disease, 2.1323785396701751E-4, 4.4283294159368431 +E-6, 1376, 4224420, 3.3947194253425559E-11 Use of uninitialized value in subtraction (-) at Creating_table_ZZI_Pa +ul.pl line 1210. Use of uninitialized value in subtraction (-) at Creating_table_ZZI_Pa +ul.pl line 1210. Use of uninitialized value in multiplication (*) at Creating_table_ZZI +_Paul.pl l ine 1211. Use of uninitialized value in addition (+) at Creating_table_ZZI_Paul. +pl line 12 16. Use of uninitialized value in subtraction (-) at Creating_table_ZZI_Pa +ul.pl line 1217. Use of uninitialized value in subtraction (-) at Creating_table_ZZI_Pa +ul.pl line 1217. Invalid n: 0