Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3457498
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:52:02+00:00 2026-05-18T09:52:02+00:00

I’ve got into this habit of always using unsigned integers where possible in my

  • 0

I’ve got into this habit of always using unsigned integers where possible in my code, because the processor can do divides by powers of two on unsigned types, which it can’t with signed types. Speed is critical for this project. The processor operates at up to 40 MIPS.

My processor has an 18 cycle divide, but it takes longer than the single cycle barrel shifter. So is it worth using unsigned integers here to speed things up or do they bring other disadvantages? I’m using a dsPIC33FJ128GP802 – a member of the dsPIC33F series by Microchip. It has single cycle multiply for both signed and unsigned ints. It also has sign and zero extend instructions.

For example, it produces this code when mixing signed and unsigned integers.

026E4  97E80F     mov.b [w15-24],w0
026E6  FB0000     se w0,w0
026E8  97E11F     mov.b [w15-31],w2
026EA  FB8102     ze w2,w2
026EC  B98002     mul.ss w0,w2,w0
026EE  400600     add.w w0,w0,w12
026F0  FB8003     ze w3,w0
026F2  100770     subr.w w0,#16,w14

I’m using C (GCC for dsPIC.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:52:03+00:00Added an answer on May 18, 2026 at 9:52 am

    I think we all need to know a lot more about the peculiarities of your processor to answer this question. Why can’t it do divides by powers of two on signed integers? As far as I remember the operation is the same for both. I.e.

    10/2 = 00001010 goes to 00000101

    -10/2 = 11110110 goes to 11111011

    Maybe you should write some simple code doing an unsigned divide and a signed divide and compare the compiled output.

    Also benchmarking is a good idea. It doesn’t need to be precise. Just have a an array of a few thousand numbers, start a timer and start dividing them a few million times and time how long it takes. Maybe do a few billion times if your processor is fast. E.g.

    int s_numbers[] = { etc. etc. };
    int s_array_size = sizeof(s_numbers);
    unsigned int u_numbers[] = { etc. etc.};
    unsigned int u_array_size = sizeof(u_numbers);
    int i;
    int s_result;
    unsigned int u_result;
    
    /* Start timer. */
    
    for(i = 0; i < 100000000; i++)
    {
      i_result = s_numbers[i % s_array_size] / s_numbers[(i + 1) % s_array_size];
    }
    
    /* Stop timer and print difference. */
    
    /* Repeat for unsigned integers. */
    

    Written in a hurry to show the principle, please forgive any errors.

    It won’t give precise benchmarking but should give a general idea of which is faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.