DIGIT-ARC read-only archive · snapshot: July 23, 2026

Need php help

2 posts · originally from https://geek.digit.in/community/threads/need-php-help.126492/

Dangerous Dave
Dangerous Dave Original post #1
May 4, 2010 at 10:50 PM
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
khmadhu #2
May 5, 2010 at 1:57 PM
$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