Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 musing on the Monastery: (13)
As of 2014-07-24 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (165 votes), past polls