Como dividir Binarios

Lord Chrono
08 de Abril del 2004
Hello.
Hola a todos necesito su ayuda alguien sabe como se dividen Binario necesito un ejemplo para realizarlo en C++ si alguien me ayuda se lo agredeceria de ante mano.

Oliverio
08 de Abril del 2004
Todo depende de la presiscion que desees logras puedes usar cuchillo() o visturi() :D
La verdad es que no te entendi la pregunta, si me pones un ejemplo a lo mejor entre los dos hacemos 1 peso

noel solw
08 de Abril del 2004
Te envio un programa en C++ que realiza todas las operaciones con numeros binarios/
Elegi lo que necesites.

// program k6_27.CPP - page 114
// bitwise operations : Calculator.
// c++ exercices book - dr. gershon kagan (first edition : 2001)
// 4/9/2001
// written in Borland CPP ver 3.1

#include <conio.h>
#include <iostream.h>
#include <iomanip.h>

void Frame()
{
clrscr();
cout << "bitwise operations : Calculator." << endl << endl;
cout << "press : " << endl;
cout << setw(20) << "[+]" << " for addition" << endl;
cout << setw(20) << "[-]" << " for subtraction" << endl;
cout << setw(20) << "[*]" << " for multiplication" << endl;
cout << setw(20) << "[/]" << " for division" << endl;
cout << setw(20) << "[%]" << " for remainder" << endl;
cout << setw(20) << "[ESC]" << " for exit" << endl << endl;
} // FRAME

unsigned long GetNum(char x)
{
unsigned long num;
cout << x << " = ";
cin >> num;
return num;
} // GET NUM

unsigned long plus(unsigned long a,unsigned long b)
{
unsigned long c;
while(b)
{
c = a ^ b;
b = a & b;
b <<= 1;
a = c;
}
return a;
} // PLUS

unsigned long minus(unsigned long a,unsigned long b)
{
b = plus(~b,1);
return plus(a,b);
} // PLUS

unsigned long mult(unsigned long a,unsigned long b)
{
unsigned long bit_check = 1,result = 0,a_holder = a,
zero_check = 0xffffffff;
while(b & zero_check)
{
if(b & bit_check)
result = plus(result,a_holder);
bit_check <<= 1;
a_holder <<= 1;
zero_check <<= 1;
}
return result;
} // MULT

unsigned long div(unsigned long a,unsigned long b)
{
unsigned long e = 0x4000000,f = b,target = 0;
while(!(a & e))
e >>= 1;
while(!(f & e))
f <<= 1;
while(!(minus(f,b) & 0x8000000))
{
target <<= 1;
if(a >= f)
{
a = minus(a,f);
target |= 1;
}
f >>= 1;
}
return target;
} // DIV

unsigned long mod(unsigned long a,unsigned long b)
{
return a - mult(div(a,b),b);
} // MOD


void Process()
{
unsigned long a,b,c;
for(;;)
{
Frame();
char choice = getch();
switch(choice)
{
case '+' :
case '-' :
case '*' :
case '/' :
case '%' : a = GetNum('a');
b = GetNum('b');
cout << a << " " << choice << " " << b << " = ";
switch(choice)
{
case '+' : cout << plus(a,b) << endl;
break;
case '-' : cout << minus(a,b) << endl;
break;
case '*' : cout << mult(a,b) << endl;
break;
case '/' : cout << div(a,b) << endl;
break;
case '%' : cout << mod(a,b) << endl;
break;
}
getch();
break;
case 27 : return;
} // SWITCH CHOICE
} // FOR EVER
} // PROCESS

void main()
{
Process();
cout << "end of program - good bye ! ! !" << endl;
getch();
} // MAIN

/*
bitwise operations : Calculator.

press :
[+] for addition
[-] for subtraction
[*] for multiplication
[/] for division
[%] for remainder
[ESC] for exit

35 + 8 = 43

35 - 8 = 27

35 * 8 = 280

35 / 8 = 4

35 % 8 = 3

end of program - good bye ! ! !
*/