Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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).

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 drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2016-09-26 21:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (491 votes). Check out past polls.