Need php help

Status
Not open for further replies.

Dangerous Dave

Digital Marketer
I have just started learning PHP . I am new to it. i have read of logical and bitwise negation in the book that i have bought. I am not able to understand it and following php code.

<?php
$num1=25.59;
$num2=30;
$num3=(~$num1)+(!$num2);
echo "The sum of Bitwise number 25.59 and Logical number 30 is".$num3;
?>

The outcome was "The sum of Bitwise number 25.59 and Logical number 30 is-26"

How the sum come out to be -26

Please explain me.

Thanks in advance.
 

khmadhu

change is constant!!
$num1 25.59 will automatically takes Ceil value 26.

~$num1 will bitwise negate the value and u will get -26.

!$num2 here ! this is performing normal operation(regular negate) not bitwise negate.

so nothing is printing in that place.

u need to use some built in functions to perform theses operations..

check this
*php.net/manual/en/language.operators.bitwise.php
 
Status
Not open for further replies.
Top Bottom