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

Re: update-alternatives broken?

On Wed, Sep 12, 2001 at 02:35:53PM -0400, Matt Zimmerman wrote:

> I think you may be correct in thinking that it may be a floating point
> problem.  I added some debugging statements to update-alternatives (diff
> attached), and it looks like for $var = 1, $var-- is setting $var to 0.5
> (!):

It looks like the problem is with incrementing the undefined value.  When
this is done (on my Hercules system), the result is a value (distinct from
1) which compares equal to 1, but when 1 is subtracted, becomes 0.5.  So:

perl -e '$a++; print "$a\n";'                                                   

Should and does print 1.

perl -e '$a++; print "yes" if $a == 1;'                                         

Should and does print yes.  However, 

perl -e '$a++;$a--; print "$a\n";'

Should print 0, and prints 0.5.

perl -e '$a++; $b = $a - 1; print "$b\n";'                                      

Should also print 0, and also prints 0.5.

perl -e '$a = 1; $a--; print "$a\n";'                                           

Should and does print 0.

Indications are that this doesn't happen on real live 390 hardware, and only
under Hercules, so I'm hesitant to call it a Perl bug.  Can anyone with
Hercules internals knowledge help me track this down further?

 - mdz

Reply to: