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 an upload field while uploads files to the server. The
Right now, I have: RewriteRule ^([^/\.]+)?$ index.php?id=$1 [L] to match any username at the
Right now I have a script that will get the last five files in
Right now I have 3 tables: User, Roles, and User_Roles for the many-to-many association.
Right now I have a function, in a class that is used to listen
Right now I came across the Observer/Observable pattern where I have my Observable notify
this is what i have right now Drawing an RSS feed into the php,
right now I have a huge Solution in which we use javascript alerts via
Right now I have: Time.strftime(%I:%M%p) which gives me the hr:min AM/PM format which I
Right now, I have a table whose primary key is an auto_increment field. However,

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.