Jump to content
Sign in to follow this  

Unexpected result with unsigned short int type

Recommended Posts

I wrote a simple code in C, but when I port it to mspgcc it doesn't give me the right value. This is my code:


#include "uart1.h"
int putchar(int c)
  return uart1_putchar(c);

int main(void) 
    unsigned short int xk=3588, yk=47541, yk1, sig=10, de=1;

    unsigned long xk1;
    xk1=( xk+(sig*((unsigned long)yk-xk)*de));

    yk1=xk1 % 65535;




THe result that I want is xk1=443118 and yk1=49908, but in mspgcc it gives me xk1=fffbc2ee and yk1=49902

I'm working with msp430-gcc-4.4.3

any idea


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...