log function

Lloyd Kremer kremer at cs.odu.edu
Tue Jun 25 23:36:12 AEST 1991


In article <1991Jun21.113211 at cs.utwente.nl> stadt at cs.utwente.nl (Richard van de Stadt) writes:
>
>I get the error message
>log: SING error
>
>when the statement 
>store_control_parameter (mean / log (1/get_acceptance_ratio_X0()))
>is executed.
>
>Does anybody know what the error message means?
>
>The same message appears when I split up the statement:
>tolog = 1/get_acceptance_ratio_X0();   /* tolog has then value 1.25 */
>loggie = log (tolog);  /* now this is the statement that causes the message */
>store_control_parameter (mean / loggie);
>

SING error is the result of an operation producing a mathematical singularity.
For the log() function, a singularity exists for log(0.0).  I believe taking
the log of a negative number would cause a DOMAIN error rather than SING.

So the log() function thinks it's being handed a 0.0 argument.

The log() function takes a double and returns a double, yet I see the integral
constant "1" in the argument to log in your code.  If no prototype is in scope,
maybe an integral bit pattern is being passed to log(), which then interprets
the pattern as a double representing the value 0.0 .  As a first step, I would
explicitly cast log's argument to double and see what happens.

Passing the type float will not work either unless the compiler does automatic
float-to-double promotion or a prototype is in scope.

					Lloyd Kremer
					Hilton Systems, Inc.
					kremer at cs.odu.edu



More information about the Comp.lang.c mailing list