online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/* Multiplico dos numeros bit a bit Diego, me parece un tanto complejo, no se puede hacer la suma bit a bit de manera facil que esta funcion? */ #include <stdio.h> int sumar (int s1, int s2) { char cy = 0; char sm1 = 0; int sm = 0; for (char j = 0; j < sizeof(int)*8; j++) { sm1 = (((s1 >> j) & 1) ^ ((s2 >> j) & 1)) ^ cy; sm = sm | sm1 << j; cy = (((s1 >> j) & 1) & ((s2 >> j) & 1)) | (((s1 >> j) & 1) ^ ((s2 >> j) & 1)) & cy; } return sm; } int main () { printf("%d + %d = %d",1234,5678,sumar(1234,5678)); } /* int A = 105; int B = 23; int resul = 0; for (char i = 0; i < sizeof(int)*8; i++){ if ((B >> i) & 1){ resul = sumar (resul, A << i); } } printf ("%d * %d = %d\n", A, B, resul); return 0; } */
#include <stdio.h> int sumar (int s1, int s2) { char cy = 0; char sm1 = 0; int sm = 0; for (char j = 0; j < sizeof(int)*8; j++) { sm1 = (((s1 >> j) & 1) ^ ((s2 >> j) & 1)) ^ cy; sm = sm | sm1 << j; cy = (((s1 >> j) & 1) & ((s2 >> j) & 1)) | (((s1 >> j) & 1) ^ ((s2 >> j) & 1)) & cy; } return sm; } int main (){ printf(%d + %d = %d,123,456,sumar(123,456)); }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue