weg22
Joined: 08 Jul 2005 Posts: 91
|
problem with data types |
Posted: Wed Apr 26, 2006 9:52 am |
|
|
The code below is outputting a value of "-66" for "rud_pwm". How is this possible if ints are by default unsigned?
Code: |
#include <16F877A.H>
#include <stdlib.h>
#include <math.h>
#fuses HS,NOWDT,NOPROTECT,PUT,NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_D6, rcv=PIN_D7, stream=PC)
void main()
{
long pwm=190;
int rud_pwm = 0;
while(1)
{
rud_pwm = (int)pwm;
fprintf(PC, "output: %d\r\n", rud_pwm);
}
}
|
|
|