Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Scientific Notation Throws Off Results.

by bl0rf (Pilgrim)
on Jan 14, 2004 at 00:22 UTC ( [id://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).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-28 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found