Created
August 22, 2010 10:13
-
-
Save rangalo/543617 to your computer and use it in GitHub Desktop.
Division without / operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Divide { | |
public static int divide(int dividend, int divisor) throws Exception { | |
int result = 0; | |
int sign = 1; | |
if (divisor == 0) { | |
System.out.println("Divide by 0 error"); | |
throw new Exception("Divide by 0"); | |
} | |
if (divisor < 0 ) { | |
sign *= -1; | |
divisor *= -1; | |
} | |
if (dividend < 0) { | |
sign *= -1; | |
dividend *= -1; | |
} | |
while (dividend > divisor) { | |
dividend -= divisor; | |
result++; | |
} | |
return result * sign; | |
} | |
public static void main(String[] args) { | |
try { | |
int res = Divide.divide(-7,-3); | |
System.out.println(res); | |
} | |
catch(Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
<VirtualHost *:80>
DocumentRoot "D:/htdocs/mvc/public/"
ServerName mvc.local
ErrorLog "error.log"
CustomLog "access.log" common
<Directory "D:/htdocs/mvc/public/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1
helllo moi ng
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
<VirtualHost *:80>
DocumentRoot "D:/htdocs/mvc/public/"
ServerName mvc.local
ErrorLog "error.log"
CustomLog "access.log" common
<Directory "D:/htdocs/mvc/public/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1