[arm-gnu] an long long problem

Ansell, John John.Ansell at CooperIndustries.com
Fri Mar 23 10:16:25 UTC 2012


> On 22/03/12 16:13, zzzh.2007 wrote:
> Hi, all,
>
> I am using sourcery_g++_lite_for_arm_eabi ( version of
> arm-2008q3-66-arm-none-eabi) in Contiki to do some programming, and
> below is my code that have problem:
>
> -----------------------------------------------
> short a,x;
> long long y;
>
> a = (short)rand();
> x = (short)rand() *10000/66536;
>
> y = a*x*x;
>
> printf( "a and x are %d, %d \n", a, x);
> printf( " y is: %lld \n", y);
>
> ----------------------------------------------
> The problem is: the y result is always wrong.
>
> I have no idea why this is happening, any help?
>
> ---------------------------------------------------------------------
---
> Zhu
> 2012-03-22
>
> ATT00001..txt
>
>
> _______________________________________________
> arm-gnu mailing list
> arm-gnu at codesourcery.com
> http://sourcerytools.com/cgi-bin/mailman/listinfo/arm-gnu

Depends what you mean by 'wrong'... The results look OK when I build it,
albeit with a slightly older compiler (2007q1).

If the results are a bit out for large values of x, maybe you meant to
divide x by 65536?
If they're miles out, it's something else :)

Cheers




More information about the arm-gnu mailing list