TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG:12095] Powers in Perl
pow10(x) = exp(log(10) * x)
Tom Veldhouse
veldy@visi.com
----- Original Message -----
From: "Mike Hicks" <hick0088@tc.umn.edu>
To: <tclug-list@mn-linux.org>
Sent: Monday, January 10, 2000 8:19 PM
Subject: [TCLUG:12095] Powers in Perl
> I have a little chunk of code below (taken pretty much verbatim from a C
> program) for calculating relative humidity using the current temperature
> and dewpoint (in degrees C) The problem is that I need a function that
> will do powers of 10, but Perl (the language I'm writing this little
> program in) only has exp() for raising e to a power (as far as I know)
>
> Does anyone either know a good trick to use or a function that I may
> have missed? Thanks
>
> {
> my ($esat, $esurf, $temp, $dewp)
> $temp = $self->{C_TEMP};
> $dewp = $self->{C_DEW};
>
> $esat = 6.11 * pow(10.0, (7.5 * $temp) / (237.7 + $temp));
> $esurf = 6.11 * pow(10.0, (7.5 * $dewp) / (237.7 + $dewp));
>
> $self->{HUMIDITY} = sprintf("%3.f",(esurf/esat) * 100));
> }
>
> --
> _ _ _ _ _ ___ _ _ _ ___ _ _ __ You're not Dave. Who are
> / \/ \(_)| ' // ._\ / - \(_)/ ./| ' /(__ you?
> \_||_/|_||_|_\\___/ \_-_/|_|\__\|_|_\ __)
> [ Mike Hicks | http://umn.edu/~hick0088/ | mailto:hick0088@umn.edu ]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-list-help@mn-linux.org
>