in reply to Re: Integer vs Float during addition
in thread Integer vs Float during addition

Ok, you took it the opposite direction. Boolean context doesn't force anything. Print forces to string. 0+ forces to number.

The string '0.00' is true, but numeric zero is false.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^3: Integer vs Float during addition
by halley (Prior) on Jun 29, 2006 at 16:10 UTC
    More specifically, string '0.00' is true but string '0' is false. This tends to surprise C-to-Perl newcomers. So if someone got a string and they weren't sure if it was natural or sprintf-formatted, it could lead to bugs in logic.
    use Data::Dumper; for (0, '', '0', '00', '0.0', '0.00', undef) { print (($_? 'TRUE' : 'FALSE'), ': ', Dumper($_)); }

    --
    [ e d @ h a l l e y . c c ]