I know that was my inadvertent mistake. I was looking for floating point value 
conversion, that you have rightly pointed out to below. Thank you and Peter for the 
useful solutions. It will work for me.

Thank you all!
perdeep

Perdeep K. Mehta, PhD
Group Leader, Bioinformatics
Hartwell Center for Bioinformatics & Biotechnology
St. Jude Children's Research Hospital
Memphis, TN 38105-2794
Tel: 901-495 3774
http://www.hartwellcenter.org


-----Original Message-----
From: Bruce Hudson [mailto:[EMAIL PROTECTED]
Sent: Friday, February 27, 2004 3:23 PM
To: Mehta, Perdeep
Subject: Re: [Perl-unix-users] conversion between exponential and
corresponding


 
 
> I need help to convert an exponential value such as 10e-5 to its
> integer value and vice versa in a perl script.

    I have to confess I am not sure precisely what you are looking for.
Normally where expressing numeric values in an exponential format the
mantissa is in the range [1, 10). By "10e-5" do you actually mean 
"10 * 10^(-5)" or just "10^(-5)". In either case, since the value is
less than 1, its "integer value" is 0. Given that converting to an
integer is not a 1:1 function, the whole concept of "vice versa" becomes
a bit iffy.

    Assuming that all you want is the simplest case of switching between
decimal and exponential notations is a simple matter of using "printf"
or sprintf.

        $number = sprintf ('%d', $value);       # 10e-5 -> 0
        $number = sprintf ('%f', $value);       # 10e-5 -> 0.000100
        $number = sprintf ('%e', $value);       # 10e-5 -> 1.000000e-04

Based on exactly what you are looking for you will have to play with
these a bit but they should give you what you are looking for.
--
Bruce A. Hudson                         | [EMAIL PROTECTED]
UCIS, Networks and Systems              |
Dalhousie University                    |
Halifax, Nova Scotia, Canada            | (902) 494-3405



_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to