avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] sqrt problems


From: Russell Shaw
Subject: Re: [avr-gcc-list] sqrt problems
Date: Mon, 20 Oct 2003 10:30:28 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030311 Debian/1.2.1-10

Jack Valmadre wrote:
Hi,

I'm going to write a program that uses the sqrt() function to work out the 
hypotenuse of a right angled triangle.  I'm testing the function using this 
program on a 2313, but all the pins on PORTB go low.

#include <avr/io.h>
#include <math.h>

int main(void) {
 DDRB = 0xFF;
 PORTB = sqrt(9);
 return 0;
}

How can I fix this?

You might see the answer on the pins for ~0.1us. Try:

#include <avr/io.h>
#include <math.h>

int main(void) {
 DDRB = 0xFF;
 PORTB = sqrt(9);
 while(1){};
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]