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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this