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 7746785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:22:07+00:00 2026-06-01T10:22:07+00:00

Right now I’m doing as follow: uint8_t ManualFlow = 40; // 0 -> 255

  • 0

Right now I’m doing as follow:

uint8_t ManualFlow = 40; // 0 -> 255     Unsigned Char

uint24_t ME; // 0 -> 16777215 Unsigned Short Long
ME = (uint24_t) ManualFlow*10; // Have to make this hack otherwise malfunction in calculation
ME /= 6;
ME *= (80 - 60);
ME /= 100;
ME *= 414;

The end result:

40*10 = 400
400/6 = 66
66*20 = 1320
1320/100 = 13
13*414 = 5382

What I would Love is similar to this:

4/60 = 0,0667 * 20 * 4188 * 0,998 = 5576 (more accurate).

How can I do this more accurate without using floats or doubles, and most important
not increase my code size too much.

Kind Regards
Sonite

  • 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-01T10:22:08+00:00Added an answer on June 1, 2026 at 10:22 am

    conclusion:

    My initial code had not so good accuracy and was “this big”.

    By doing this below I increased the code with “38 byte” and gained better accuracy

    ME = (uint24_t) ManualFlow*100;
    ME /= 6;
    ME *= (Port[2].AD - Port[3].AD);
    ME /= 100;
    ME *= 414;
    ME /= 10;
    

    The best accuracy I got by doing fixed-point but it increased the code to much “1148 bytes ->

    // Utility macros for dealing with 16:16 fixed-point numbers
    #define I2X(v) ((int32_t) ((v) * 65536.0 + 0.5))    // Int to Fix32
    #define X2I(v) ((int16_t) ((v) + 0x8000 >> 16))     // Fix to Int
    
    ME = I2X(ManualFlow*10); //400 * 65536.0 + 0.5 =   26214400
    ME = I2X(ME/6); // 26214400 / 6 = 4369066
    ME = I2X(ME * 20); // = 87381320
    ME = I2X(ME / 100); // = 873813
    ME = I2X(ME * 414); // 361758582
    ME = X2I(ME); // 158FFF76 + 8000 >> 16 15907F76 >> 16 = 5520
    

    Hope it can help some one else!

    Kind Regards
    Sonite

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

Sidebar

Related Questions

Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as
Right now I'm doing something like this: RewriteRule ^/?logout(/)?$ logout.php RewriteRule ^/?config(/)?$ config.php I
Right now I have an SSIS package that runs every morning and gives me
Right now, I have two Eclipse projects - they both use Maven 2 for
Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
Right now, I have three models Post, Comment and User (using Devise ) associated
Right now, I have a domain entity named StyleBundle. This StyleBundle takes a list
right now i have this <script type='text/javascript'> $(#beau).click(function(){ $(#beau).animate({margin-Top: 738px}, fast); }); </script> and
Right now any new UIViewController added to my storyboard needs to have a class
Right now I have some TabItems in my App which are implicitly styled. I

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.