Jump to content

Bug In 32 Bit Math...


Recommended Posts

SB 6.15

target is a PIC18F4620

#include <system.h>


unsigned char tabel[]={23,57,18,144,213};

unsigned long var;

void main(void)
{
 var = 95;
 
 var = tabel[3];

 while(1);
}

This code example compiles fine but after "var = tabel[3];" var has a wrong value!

(23 instead of 144)

 

#include <system.h>


unsigned char tabel[]={23,57,18,144,213,177};

unsigned char i;

unsigned long var;

void main(void)
{
 var = 95;
 
 i = 4;
 
 var = tabel[i];

 while(1);
}

This one goes wrong as well, here var has value 0 instead of 213.

 

When I declare "var" as unsigned char or unsigned short, then it works fine.

 

Grtz, Teuniz

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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.

Loading...
×
×
  • Create New...