swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Negative double weirdness


From: Steve Emsley
Subject: Re: Negative double weirdness
Date: Wed, 1 Jul 1998 01:26:49 +0100

Marcus,

Sorry, I was taking that piece of code out of context. Also I thought
I had solved the problem . If fact my solution, although it worked,
is, I suspect, a side-effect.

The essence of my problem is:
      ...
      rad *= pow(transmission, airmass);
      printf(" %e %e %e\n",rad,transmission,airmass);
      ...
gives output (in either v1.1 or v1.2)

 3.404318e-01 6.410000e-01 1.686079e+00
 8.004245e-01 7.974000e-01 1.686079e+00
 9.691089e-01 8.744000e-01 1.686079e+00
 9.587074e-01 8.930000e-01 1.686079e+00
 9.049497e-01 9.218000e-01 1.686079e+00
 8.223062e-01 9.610000e-01 1.686079e+00

where, furthur down the line, I output rad as:

 0.3404 0.8004 0.9691 0.9587 0.9049 0.8223

This row vector matches the first column as it should.

HOWEVER, if I comment out the printf statement:

      ...
      rad *= pow(transmission, airmass);
      // printf(" %e %e %e\n",rad,transmission,airmass);
      ...

in v1.1 I get the identical output row vector:

 0.3404 0.8004 0.9691 0.9587 0.9049 0.8223

but in v1.2 I get this:

-0.7206 -1.1725 -0.0000 -0.0000 -0.0000 -0.0000

Basically, as long as I printf("%e\n",transmission) I get the correct
answer. Well, I'm beginning to wonder what the correct answer is!
Although the routine does produce figures that compare well with the
literature (at least using v1.2 swarm, that is).

The essence of my problem is:

1. How can printing a variable change the outcome of a calculation?
2. Why does this happen with swarm v1.2 but not v1.1?

 
I'm using RedHat5.0 but have upgraded to gcc2.8.0.

What is a toolchain? Although I'm feeling like taking a chain-saw to
my machine!

Thanks for taking a look at this - I'm sure there's far more
interesting stuff going on at ALife.

Steve.
-- 
---------------------------------------------------------------------
 Steve Emsley                 Ecosystems Analysis & Management Group
 address@hidden              University of Warwick, England
 http://www.oikos.warwick.ac.uk/~sme/           (+44) (0)1598 753648
---------------------------------------------------------------------

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]