mformazhar1980
Junior Member level 1
dividend+((divisor) >> 1
hi i have this small code and i am trying to compile it on https://www.delorie.com/djgpp/compile/ but find myself unlucky
can any body tell me why is it happening and what these errors mean
my code is as follows
#include <stdio.h>
#include <math.h>
#define DIV(Dividend,Divisor) (((Dividend+((Divisor) >> 1))/(Divisor)))
int Ret_Val=0;
unsigned int Hi_Lim = 652;
unsigned int Lo_Lim = 155;
unsigned int Ref_Val_Hi = 475;
unsigned int Ref_Val_Lo = 372;
unsigned int Value = 0;
unsigned int Mask = 0;
int main(void)
{
printf("Enter a value between 155 to 652=");
scanf("%d",&value);
if((Value > Hi_Lim) || (Value < Lo_Lim))
{
Ret_Val = 229;
printf("error\n");
}
else
{
if((Value > Ref_Val_Lo) && ( Value < Ref_Val_Hi))
{ {
Ret_Val = 0;
printf("0x00 \n");
}
if(Value < Ref_Val_Lo)
{
Value -= Ref_Val_Lo;
Value >>= 1;
Value = DIV(Value,100);
Mask |= 128;
printf("value1= %d \n",Value);
printf("mask1= %d \n",Mask);
}
if(Value > Ref_Val_Hi)
{
Value -= Ref_Val_Hi;
Value >>= 1;
Value = DIV(Value,100);
Mask = 0;
printf("value2= %d\n",Value);
printf("mask2= %d \n",Mask);
}
}
Ret_Val |= Mask;
printf("value1= %d ",Ret_Val);
return 0;
}
}
looking forward if some one help me trying to correct this code
thanks
regards
hi i have this small code and i am trying to compile it on https://www.delorie.com/djgpp/compile/ but find myself unlucky
can any body tell me why is it happening and what these errors mean
cc1: warnings being treated as errors
/tmp/http.13856.c: In function `main':
/tmp/http.13856.c:75: warning: control reaches end of non-void function
my code is as follows
#include <stdio.h>
#include <math.h>
#define DIV(Dividend,Divisor) (((Dividend+((Divisor) >> 1))/(Divisor)))
int Ret_Val=0;
unsigned int Hi_Lim = 652;
unsigned int Lo_Lim = 155;
unsigned int Ref_Val_Hi = 475;
unsigned int Ref_Val_Lo = 372;
unsigned int Value = 0;
unsigned int Mask = 0;
int main(void)
{
printf("Enter a value between 155 to 652=");
scanf("%d",&value);
if((Value > Hi_Lim) || (Value < Lo_Lim))
{
Ret_Val = 229;
printf("error\n");
}
else
{
if((Value > Ref_Val_Lo) && ( Value < Ref_Val_Hi))
{ {
Ret_Val = 0;
printf("0x00 \n");
}
if(Value < Ref_Val_Lo)
{
Value -= Ref_Val_Lo;
Value >>= 1;
Value = DIV(Value,100);
Mask |= 128;
printf("value1= %d \n",Value);
printf("mask1= %d \n",Mask);
}
if(Value > Ref_Val_Hi)
{
Value -= Ref_Val_Hi;
Value >>= 1;
Value = DIV(Value,100);
Mask = 0;
printf("value2= %d\n",Value);
printf("mask2= %d \n",Mask);
}
}
Ret_Val |= Mask;
printf("value1= %d ",Ret_Val);
return 0;
}
}
looking forward if some one help me trying to correct this code
thanks
regards