Jump to content
Sign in to follow this  
Bart Goossens

Divide By 8

Recommended Posts

Division by 8 is apperantly implemented by a simple right shift by 3. Things go wrong when a signed variable, which is negative, is divided by 8.

 

For example:

 

short test;

 

test=-1;

test=test/8;

lprintf("%d", test);

 

The result is 8191.

 

When shifting a signed value, make sure the highest bit value is preserved.

This can easily be done this way:

rlf valueH, W

rrf valueH, F

rrf valueL, F

 

I'm using BoostC 6.01 compiling for a 16F877

Edited by Bart Goossens

Share this post


Link to post
Share on other sites

Bart,

 

I'm glad to see a serious bug gets such a quick reaction.

 

Yes, this is a poor show :blink: - sorry, somehow it was forgotten, thanks for the reminder.

 

This one is now on our bug list, so won't be forgotten.

 

Regards

Dave

Share this post


Link to post
Share on other sites
I'm glad to see a serious bug gets such a quick reaction.  :o

 

Sometimes we don't reply to some posts but this doesn't mean we don't read them. I read this one the same day it was posted and put this job on my todo list.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Sometimes we don't reply to some posts but this doesn't mean we don't read them. I read this one the same day it was posted and put this job on my todo list.

 

That, off course, is something I couldn't have known. A small reply saying "we're working on that" or even "we won't fix that one", puts me out of the dark. Then I know weither I have to put energy in writing my own math routines (which I did), or can wait for the bug to be fixed.

Also, when I go through the trouble of filing a bug report, it's nice to get some feedback. I have some more bug reports ready, but was hesitant to post them because of the lack of response. I will post the later.

Please, don't take these mails too negative. I really like the compiler and the work you've done a lot, and I'm only trying to help make things even better.

 

Greetings,

Bart

Share this post


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...
Sign in to follow this  

×
×
  • Create New...