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

  • Home
  • SEARCH
  • 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 7847253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:50:15+00:00 2026-06-02T17:50:15+00:00

I have a formula in c that looks like this: X = (a *

  • 0

I have a formula in c that looks like this:

X = (a * X) / b;

This is used to rescale X with a/b. However X is 16 bit unsigned int and multiplication with a could easily overflow. How could I do this calculation using just integers with an accurate result.

I could of course use floating point arithmetic, but there is a high chance this operation will work on a processor without floating point hardware.

EDIT: I forgot to say that a and b are both 32 bit unsigned integers.
Well my answer was to rightshift a and b until they both fit in 16 bits. That way a * X is 32 bits max and the final calculation is accurate.

  • 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-06-02T17:50:17+00:00Added an answer on June 2, 2026 at 5:50 pm

    You can promote a to a bigger data type, for example:

    X = ((long)a * X) / b;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a formula that looks like this in VBA: ActiveCell.FormulaR1C1 = =LOOKUP(ETG_C,RC[-10],RC[-8]) what
I have an excel that looks like this: I need a formula that will
I have a BUSINESS table that looks like this: BUSINESS_ID | BRN | CODE
I have a need to iterate through an amortization formula, which looks like this:
I have a switch statement in a Crystal Report that looks like this: stringvar
I have an Address class in C# that looks like this: public class Address
i have a dataset that looks like this id, value1,value2,value3,value4,value5...value200 (i am showing only
is there a way in Excel to have a formula that does something like
I have a formula like this which works fine on Excel/OOCalc applications: =SUMPRODUCT(--($Panels.$A$5:$A$6999=K$80);--($Panels.$B$5:$B$6999=K$81);INDEX($Panels.$C$5:$J$6999;0;MATCH(Voc;$Panels.$C$3:$J$3;0))) Since
I have data that looks like the following: ID | Location | Attendees |

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.