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

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

Re: [avr-gcc-list] Type casting from 32 bit to 64 bit ... doesnt seem to


From: Dmitry K.
Subject: Re: [avr-gcc-list] Type casting from 32 bit to 64 bit ... doesnt seem to work
Date: Sat, 11 Jun 2005 13:33:18 +1100
User-agent: KMail/1.5

On Saturday 11 June 2005 03:16, intiha Ho gai wrote:
> Hi,
> I dont know if this an avr-gcc issue, but it seems that if i am try to
> typecast variables in an array of uint32_t to uint64_T as follows:
> sumX += (uint64_t)array.x;
> (where sumX is an uint64_t var, while array.x is uint32_t),
> then this summation doesnt seem to work i.e. my summation values are
> just totally incorrect.
> however, when i change the type of array.x to be uint64_t and do no
> typecasting (although the values of x are within the range of 32 bit)
> the results are correct.
> Any insight why this is so?

The next program run fine (avr-gcc 3.3.5):

#include <stdint.h>

volatile struct {
    uint32_t x;
} array = { 123456789 };

uint64_t main ()
{
    uint64_t sum = -123456789;
    /* to clean `sum' fully, 64-bits operation is needed        */
    sum += (uint64_t) array.x;
    return sum;
}

Dmitry.





reply via email to

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