Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 04-05-2010, 10:50 PM   #1 (permalink)
Linux Noob
 
Dangerous Dave's Avatar
 
Join Date: Mar 2009
Location: Gurgaon, India
Posts: 169
Post Need php help


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.
Dangerous Dave is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 05-05-2010, 01:57 PM   #2 (permalink)
change is constant!!
 
khmadhu's Avatar
 
Join Date: Jan 2010
Location: Bengaluru
Posts: 445
Default Re: Need php help

$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
http://php.net/manual/en/language.operators.bitwise.php
__________________
If you really wanna think, try to think from Atom to Universe!!

cpu: core i5 2500k, mobo: DP67BG, RAM:Corsair 8GB(4x2) 1600 Mhz, XFX HD 5770, 1TB seagate 6Gbps 7200 rpm , SAGA II 500W
khmadhu is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best book to learn PHP And MySQL? walkmanguru Programming 13 07-05-2010 09:16 AM
PHP Institutes in Delhi udaydeep_1990 Training Institutes 0 12-04-2010 07:38 PM
php file upload error meghraj Programming 1 27-02-2010 12:41 PM
Installing Apache, PHP on Windows Deep Tutorials 25 20-12-2005 12:38 PM
Help a PHP newbie tuxfan QnA (read only) 3 22-07-2005 07:01 PM

 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:17 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2