Robert,
I tried the settype() and it seems to be the route to take.  I now get a few
of the image lines to appear, and I'll work on it until I get them all
going.
Thanks
hugh
----- Original Message -----
From: Robert V. Zwink <[EMAIL PROTECTED]>
To: Hugh Danaher <[EMAIL PROTECTED]>; Php-General
<[EMAIL PROTECTED]>
Sent: Wednesday, September 05, 2001 1:38 PM
Subject: RE: [PHP] negative infinity is unreachable


> I believe your problem is due to ambiguous type casting.  Your if
statement
> tests a DOUBLE against a STRING.  Try:
>
>      $x_distance=20+($year-($current_year-9))*20;
>      $high_distance=420-round(log($high[$year])*75,0);
>      $low_distance=420-round(log($low[$year])*75,0);
> settype($high_distance, "string");
> settype($low_distance, "string");
>
> Or add this line to your code to see what I'm talking about:
> echo "High distance ".gettype ($high_distance)." $high_distance<BR>";
> echo "Low distance ".gettype ($low_distance)." $low_distance<BR>";
>
> Will show that $high_distance and $low_distance are of type DOUBLE.
>
> I'm not sure how this will affect your calculation, but the if condition
> will at least evaluate to TRUE when $high_distance or $low_distance ==
> "INF", you can try to remove the quotation marks, it didn't work for me
> though.  The only way I could get it to work was by changing the type.
>
> Maybe your could change your if condition:
> if(gettype($variable_name)=="DOUBLE"){ . . .
>
>
> Hope this helps!
> Robert Zwink
> http://www.zwink.net/daid.php
>
>
> -----Original Message-----
> From: Hugh Danaher [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 05, 2001 3:46 PM
> To: Php-General
> Subject: [PHP] negative infinity is unreachable
>
>
> HELP!
>
> I have been trying variations of the code posted below with little
success.
> The log() function generates a -INF statement when trying to calculate the
> log of zero or the log of an empty value in the associative array.  With
the
> "IF then unset() " statements in place, the total contents of log_high[]
and
> log_low[] arrays become empty.  Without the "IF then unset()" statements
the
> arrays are full but the program times out because it can't use INF in
> imageline().  I've gone through various rewrites on this code block but
have
> come up with nothing that works, and I need professional help (but that's
a
> different story).
>
> Thanks,
> hugh
>
> Failing code:
>
> for ($year=($current_year-5);$year<=($current_year+1);$year++)
>      {
>      $x_distance=20+($year-($current_year-9))*20;
>      $high_distance=420-round(log($high[$year])*75,0);
>      $low_distance=420-round(log($low[$year])*75,0);
>      if ($high_distance=="INF")                               / / INF is a
> double
>          {
>          unset($high_distance);
>          }
>       if ($low_distance=="INF")
>          {
>          unset($high_distance);
>          }
>      if (isset($high_distance) and isset($low_distance))
>         {
>
> imagettftext($image,5,0,($x_distance),($high_distance),$black,$font2,"n");
>
> imagettftext($image,5,0,($x_distance),($low_distance),$black,$font2,"n");
>
>
imageline($image,$x_distance),$high_distance,($x_distance),$low_distance,$re
> d);
>         }
>     $log_high[$year]=$high_distance;
>     $log_low[$year]=$low_distance;
>      }
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to