autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autoconf macros, portable arithmetic


From: Stepan Kasal
Subject: Re: autoconf macros, portable arithmetic
Date: Fri, 25 Feb 2005 09:04:09 +0100
User-agent: Mutt/1.4.1i

Hi,

On Fri, Feb 25, 2005 at 08:14:34AM +0100, Harald Dunkel wrote:
> If you put some other values here, then you get
> 
> 0.007 > 0.42

yes, you are right.  But it's easy to fix paul code:

# Example inputs
a=0.011
b=0.10

newline='
'

both=`echo "$a$newline$b" | sed 's/\.0*/./g'`
sorted=`
  echo "$both" | {
    # Use POSIX sort first, falling back on traditional sort.
    sort -t. -k1,1n -k1,1 -k2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 2>/dev/null ||
    sort -t. +0n -1 +0 -1 +1n -2 +1 -2 +2n -3 +2 -3 +3n -4 +3 -4
  }
`
echo $sorted
if test "x$both" = "x$sorted"; then
  echo "$a <= $b"
else
  echo "$a > $b"
fi

But to be true, I see no reson to delete the zeros, so I think the following
would be enough:

both=$a$newline$b

Have a nice day,
        Stepan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]