Non Restoring Division Algorithm Implementation in C
This is a Dynamic program for the implementation of the NON RESTORING Division Algorithm in C Language. Non Restoring Division uses Left Shift Operations, Twos' Compliment and Binary Addition. Screenshots[Demo] The Code #include<stdio.h> #include<malloc.h> int *a,*q,*m,*mc,*c,n,d; int powr(int x,int y) { int s=1,i; for(i=0;i<y;i++) s=s*x; return s; } void print(int arr[],int n) { int i; for(i=0;i<n;i++) printf("%d ",arr[i]); } void bin(int n, int arr[]){ int r, i = 0; do{ r = n % 2; n /= 2; arr[i] = r; i++; }while(n > 0); } void set(int array[], int x){ int i,tmp[20]={0}; for(i = x -1; i >=0; i--) tmp[x-1-i]=array[i]; for(i=0;i<x;i++) array[i]=tmp[i]; } int len(int x) { int i=0; while(powr(2,i)<=x) i++; return ++i; } void addBinary(int a1[], int a2[]) { int bi[2]={0},ca[20]={0}; int t=len(n),tmp=0; int *su=(int*)malloc(sizeof(int)*len(n)); while(t...
Comments
Post a Comment