Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Scientific Notation Throws Off Results.

by bl0rf (Pilgrim)
on Jan 14, 2004 at 00:22 UTC ( #321151=note: print w/ replies, xml ) Need Help??


in reply to Scientific Notation Throws Off Results.

Get rid of $len and use the numbers themselves:

if (($answer < 1000) || ($len1 > 1e14)) { $type = "b/s"; }elsif (($answer >= 1000) && ($answer <= 1e6)) { $type = "Kb/s"; $answer = substr($answer, 0, 1)." ".$type if $len1 == 4; $answer = substr($answer, 0, 2)." ".$type if $len1 == 5; $answer = substr($answer, 0, 3)." ".$type if $len1 == 6; }elsif (($len1 > 1e6) && ($len1 <= 1e9)) { $type = "Mb/s"; $answer = substr($answer, 0, 1)." ".$type if $len1 == 7; $answer = substr($answer, 0, 2)." ".$type if $len1 == 8; $answer = substr($answer, 0, 3)." ".$type if $len1 == 9; }else{
Just do a numeric check on $answer instead of tinkering with $length. By the way, 1e6 means: one multiplied by ten to the six( ten with six zeros).


Comment on Re: Scientific Notation Throws Off Results.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://321151]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2015-07-03 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls