Level: Wannabe

Joined: Sun. Feb 23, 2014

Location: United Kingdom

Posted by Nawfal:
Tue. Nov 11, 2014 - 09:53 PM
Since the avr Gcc is not able to perform a division without truncating the float, I performed a prototype that worked well so far in Avr studio 4

I'm trying to use it within a project in Avr studio 5 and I get the following error message "control reaches end of non-void function"

here is the code:

#ifndef division
#define division
#include <stdlib.h>
#include <math.h>
#include <avr/io.h>
float divis(float x,float y);
float divis(float x,float y)
{
if((x>0) && (y>0))
return (exp(log(x)-log(y)));
if((x<0) && (y>0))
return (-exp(log(-x)-log(y)));
if((x>0) && (y<0))
return (-exp(log(x)-log(-y)));
if((y==0) && (x!=0))
return 9999;
if((x==0) && (y!=0))
return 0;
}
#endif

Any idea about what's happening ????

This topic has a solution. Jump to the solution.

## Tags:

Last Edited: Wed. Nov 12, 2014 - 10:05 AM