3588 + (10 * (47541 - 3588) * 1) when evaluated as 16-bit integers produces
49902. Cast at least one of the operands to long so you don't have
truncation problems.
Peter
On Tue, May 10, 2011 at 6:07 AM, Miriam Dali <miriamd...@yahoo.fr> wrote:
>
> Thank you for your answer , I'm really sorry my question was not clear :(
> I wrote a simple code in C, but when I port it to mspgcc it doesn't give me
> the right value. This is a part of my code:
> unsigned short int xk=3588, yk=47541, yk1, sig=10, de=1;
> unsigned long int xk1;
> xk1=( xk+(sig*(yk-xk)*de));
> yk1=xk1 % 65535;
>
> the result that I expect is xk1=443118 and yk1=49908, but in mspgcc it
> gives me xk1=yk1=49902
> I don't know where is the fault may be in the type choice?
> thanks
> --- En date de : Mar 3.5.11, M. Andree <mand...@mail.uni-paderborn.de> a
> écrit :
>
> De: M. Andree <mand...@mail.uni-paderborn.de>
> Objet: Re: [Mspgcc-users] modulo
> À: mspgcc-users@lists.sourceforge.net
> Date: Mardi 3 mai 2011, 1h11
>
> Am 03.05.2011 02:55, schrieb Miriam Dali:
> > hi,
> >
> > I want to ask questions about modulo (%), why it doesn't work, if I
> > want to have numbers between 0 and 65535 using the modulo doesn't work
> > ,the number that I get is truncated, I thought to use fmod but it seems
> consuming energy
> > any ideas?
> > thanks a lot
>
> Voir http://www.chiark.greenend.org.uk/~sgtatham/bugs.html s.v.p.
> It even has a French translation. Merci.
>
> --
> M. Andree
>
>
> ------------------------------------------------------------------------------
> WhatsUp Gold - Download Free Network Management Software
> The most intuitive, comprehensive, and cost-effective network
> management toolset available today. Delivers lowest initial
> acquisition cost and overall TCO of any competing solution.
> http://p.sf.net/sfu/whatsupgold-sd
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
>
> ------------------------------------------------------------------------------
> Achieve unprecedented app performance and reliability
> What every C/C++ and Fortran developer should know.
> Learn how Intel has extended the reach of its next-generation tools
> to help boost performance applications - inlcuding clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
>
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users