Tag: hack

  • How to find out if nth bit of a number is set to 1?

    #include <stdio.h> int main() { int val1 = 4; int val2 = 18; int mask = 1; /* mask <<= 4; */ mask = mask << 4; printf(“mask is %d\n”,mask); if ( val1 & mask ) { printf(“Bit 5 in val1 is set\n”); } if (val2 & mask ) { printf(“Bit 5 in val2 is […]

  • division using PHP

    division #!/usr/bin/php # Author : Jeffrin # jeffrin@rocketmail.com # License GNU GPL V3 # usage : php subtraction.php <?php $f=’1′; $s=’1′; echo $f – $s ; echo “\n”; ?> output Like $./divide.php # Author : Jeffrin # jeffrin@rocketmail.com # License GNU GPL V3 # usage : php divide.php 1 $