Marcus Claesson wrote:

> 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";
>     }

lt, gt etc. are used for string comparisons. Change 'lt' to < and 'gt' to >
and your code should work.


>
>
> 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...
>
> Thanks in advance!
> Marcus


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to