Skip to content

Instantly share code, notes, and snippets.

@rangalo
Created August 22, 2010 10:13
Show Gist options
  • Save rangalo/543617 to your computer and use it in GitHub Desktop.
Save rangalo/543617 to your computer and use it in GitHub Desktop.
Division without / operator
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();
}
}
}
@Tam-le-nho-cuoc
Copy link

<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

@Tam-le-nho-cuoc
Copy link

Tam-le-nho-cuoc commented May 11, 2022

<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