kepler has asked for the wisdom of the Perl Monks concerning the following question:
Good afternoon,
I would like to place a question here. I want to convert a decimal number to the scientific notation. I made the following routine, but it truncates the decimals:
sub dec2eng { ($mydecimal)=@_; $myscience = sprintf("%e", $mydecimal); return $myscience; }
For instance: the decimal number 0.99982928833 is converted to 9.998293e-001 - the number is rounded, and so I loose 5 decimals (28833).
Is there a way to do this calculation without recurring to outside perl modules?
Kind regards, Kepler
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Decimal to Scientific notation
by stevieb (Canon) on Mar 24, 2015 at 13:27 UTC | |
by kepler (Scribe) on Mar 24, 2015 at 15:57 UTC | |
by Athanasius (Archbishop) on Mar 24, 2015 at 16:09 UTC | |
by kepler (Scribe) on Mar 24, 2015 at 18:01 UTC | |
by stevieb (Canon) on Mar 24, 2015 at 16:27 UTC | |
|
Re: Decimal to Scientific notation
by karlgoethebier (Abbot) on Mar 24, 2015 at 14:28 UTC | |
by toolic (Bishop) on Mar 24, 2015 at 16:05 UTC | |
by karlgoethebier (Abbot) on Mar 24, 2015 at 16:27 UTC | |
by AnomalousMonk (Archbishop) on Mar 24, 2015 at 18:31 UTC | |
by karlgoethebier (Abbot) on Mar 24, 2015 at 19:19 UTC | |
|
Re: Decimal to Scientific notation
by Not_a_Number (Prior) on Mar 24, 2015 at 19:08 UTC |