Find the answer to your Linux question:
Results 1 to 4 of 4
hi i am trying to comapre numbers for the biggest among double type of numbers. ie 0.254 0.255 0.564 0.984 0.556 0.6566 0.5666 with this if statement if [ $max ...
  1. #1
    Just Joined!
    Join Date
    Dec 2006
    Posts
    5

    Question if [ ]

    hi i am trying to comapre numbers for the biggest
    among double type of numbers. ie
    0.254
    0.255
    0.564
    0.984
    0.556
    0.6566
    0.5666
    with this if statement
    if [ $max -lt $i ]
    if [ "$max -lt "$i" ]

    they all give this error message
    1. [: 0.37: integer expression expected
    2. [: 0.40: integer expression expected
    in that order
    but none is working. Plaese help

  2. #2
    Just Joined!
    Join Date
    Dec 2006
    Posts
    52
    Try
    if [ "$max" -lt $i ]

  3. #3
    Just Joined!
    Join Date
    Dec 2006
    Posts
    5

    but ...

    yes but the same ols errors exist
    [: 0.39 : integer expression expected

  4. #4
    Just Joined!
    Join Date
    Dec 2006
    Posts
    5

    reply

    i think if the numbers were to be normal whole numbers ( not double as in other programming languages) it would have worked alright.
    is there any way to handle such type of number with decimal points ( . ) in shell.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...