Marcus Claesson said:
> Hi there,
>
> I have a simple problem that I'm sure has been asked before (so why not
> again ;))
>
> I have a list like this:
>
> 1e-100
> 2e-100
> 1e-45
> 5e-10
> 1
> 10
> 20
>
> and want to make correct assignments:
>
> 1e-100 SMALL
> 2e-100 SMALL
> 1e-45 BIGGER
> 5e-10 BIGGER
> 1 BIGGER
> 10 BIG
> 20 BIG
>
> But with this code
>
> while (<>) {
> chomp;
> if ($_ lt 1e-50) {
> print "$_\t SMALL\n";
> } elsif (($_ gt 1e-50) && $_ lt 5) {
> print "$_\t BIGGER\n";
> } elsif ($_ gt 5) {
> print "$_\t BIGGEST\n";
> }
>
> I only get
>
> 1e-100 SMALL
> 2e-100 BIGGER
> 1e-45 SMALL
> 5e-10 BIGGEST
> 1 SMALL
> 10 SMALL
> 20 BIGGER
>
> which is not matematically correct. How do convert "floating strings" to
> floating number? I thought "lt" would be the right one to choose...
You don't need to. If you want it to be a number, use it like one. That
means using < and > instead of lt and gt.
You'll also probably want <= or >= at some points in case you get 1e-50
and 5 as input.
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]