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

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

Re: [avr-gcc-list] update on the last issue


From: intiha Ho gai
Subject: Re: [avr-gcc-list] update on the last issue
Date: Tue, 5 Apr 2005 09:28:15 -0700

Thank you. 
Okay.. i can live with that.. for now.. but my issue is.. will the
long long addition be correct?
Also if it is, then why isnt the solution for the equation to
calculate a (slope) and b(offset) coming out incorrect. For the above
code where I hand coded the values of all long longs
   table.sumX = 12338578LL;
       table.sumY = -3336078LL;
       table.sumXSquared = 7260107358192LL; 
       table.sumXY = -1646741910392LL; 
        denom = ( table.n * table.sumXSquared - table.sumX * table.sumX);
        if (denom != 0)
               a = (double)( table.n * table.sumXY - table.sumY *
table.sumX) / denom;
        b = (double)(table.sumY - a * table.sumX) / table.n;

     sprintf(OutputMsg,"**************** A=%f     B=%f ***********\r\n",a,b);
     UARTOutput(DBG_ERROR,"%s", &OutputMsg);

I get on the UART

**************** A=-0.045255     B=-106838.632813 ***********

While the actual values of a and b that i have precomputed should be a
= -0.000208 , and b = -133340.419011
Is the above code doing something fundamentally beyond the capabilities
of avr-lib? Please tell me if that is a case and coudl you suggest an
alternative to do such maths on atmel 128L?

regards
Affan

On Apr 5, 2005 12:32 AM, Haase Bjoern (PT-BEU/EMT) *
<address@hidden> wrote:
> Hi,
> 
> Expect long long support to be *extremely* inefficient for AVR. IIRC, e.g., 
> long long adds are implemented by a library function written in C that will 
> add one bit at a time ... The back-end does not supply any support for using 
> long longs so anything we have at the moment is the generic support of GCC's 
> libgcc2.
> 
> Yours,
> 
> Björn
> 
> -----Ursprüngliche Nachricht-----
> Von: address@hidden [mailto:address@hidden Im Auftrag von David Gesswein
> Gesendet: Montag, 4. April 2005 20:53
> An: address@hidden
> Betreff: Re: [avr-gcc-list] update on the last issue
> 
> Haven't played enough with the GCC avr port to have direct knowledge of
> long long in it but these should help:
> 
> http://gcc.gnu.org/onlinedocs/gcc/Long-Long.html
> 
> http://lists.gnu.org/archive/html/avr-libc-dev/2004-09/msg00038.html
> 
> >
> > Hi,
> > I did a little bit more of search and figured that if i use the long
> > long for my X, Y coordinates and the sums, I should be able to handle
> > extremely large numbers. But now When i do that, it still give me
> > incorrect results. Even when i try to assign them those high values
> > directly, it fails!!!!
> >
> ...
> 
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
> 
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>




reply via email to

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