Boolen logic operations between integer numbers

Dear All,
I would like to know the reasons why this happens:
>> 3 && -4
ans =
1
Thanks in advance for your kindly support.
Best Regards,
Josh

 Réponse acceptée

Alexandra Harkai
Alexandra Harkai le 22 Nov 2016
Modifié(e) : Alexandra Harkai le 22 Nov 2016
>> logical(3)
ans =
1
>> logical(-4)
ans =
1
So 1 && 1 = 1, according to the numeric-to-logical documentation.

2 commentaires

Guillaume
Guillaume le 22 Nov 2016
To add to this, only 0 is considered false by matlab (and many many other languages)
Thank you Alexandra Harkai and Guillaume for the valuable help.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simultaneous and Synchronized Operations dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by