[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] update on the last issue
From: |
intiha Ho gai |
Subject: |
[avr-gcc-list] update on the last issue |
Date: |
Sun, 3 Apr 2005 17:07:16 -0700 |
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!!!!
Here is my code.
table.sumX = 12338578;
table.sumY = -3336078;
table.sumXSquared = 7260107358192; <-- 252
table.sumXY = -1646741910392; <--- 253
denom = ( table.n * table.sumXSquared - table.sumX * table.sumX);
if (denom != 0)
a = ( table.n * table.sumXY - table.sumY * table.sumX) / denom;
b = (table.sumY - a * table.sumX) / table.n;
sprintf(OutputMsg,"sumX=%ld, sumY=%ld, sumXY=%ld,
sumXSquared=%ld\r\n",
table.sumX,table.sumY,table.sumXY,table.sumXSquared);
UARTOutput(DBG_ERROR,"%s", &OutputMsg);
sprintf(OutputMsg,"**************** A=%f B=%f ***********\r\n",a,b);
UARTOutput(DBG_ERROR,"%s", &OutputMsg);
This is the compile warning!
Cricket.c:252: warning: integer constant is too large for "long" type
Cricket.c:253: warning: integer constant is too large for "long" type
Cricket.c:259: warning: long int format, different type arg (arg 3)
<-- Why these warnings?
Cricket.c:259: warning: long int format, different type arg (arg 4)
<--It prints something wrong as well :(
where i have defined table as of type regTable (i know long long and
int64_t are the same but i am clutching at straws)
typedef struct regressTbl{
int16_t n ;
long long sumXY;
int64_t sumX,sumY;
long long sumXSquared;
}regTable;
Any ideas?
Thanks.
- [avr-gcc-list] update on the last issue,
intiha Ho gai <=