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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:00:28+00:00 2026-06-05T11:00:28+00:00

I am doing Arithmetic Coding now, and I have got the final start position

  • 0

I am doing Arithmetic Coding now, and I have got the final start position and distance, then I add them.
How can I convert the result to binary mode?

For example, how can I convert 0.125 decimal to 0.001 binary in C++?

void CArithmeticCoding::Encode()
{
    if ( 0 == m_input )
        return;
    printf("The input is [%s].\n", this->m_input);

    while (*m_input)
    {
        if ( *m_input == m_MPS )
        {
            DOMPS();
        }
        else
        {
            DOLPS();
        }
        ++m_input;
    }
    double ret = m_start + m_dis;

    return;
}
  • 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-05T11:00:30+00:00Added an answer on June 5, 2026 at 11:00 am

    Converting anything to binary means finding out how many of each kind of power of 2 is involved. In the case of a decimal number, the powers involved are negative.

    For .125, the sequence is like this:

    .125 x 2 =  .250 (< 1)
    .250 x 2 =  .500 (< 1)
    .500 x 2 = 1.000 (>= 1)
    .000     = 0     done
    

    So, the binary representation is 0x2^-1 + 0x2^-2 + 1x2^-3 = .001 binary. As an exercise, contrast this technique with converting a normal integer into binary representation.

    Just as regular decimals can have non-terminating patterns (like 1/3 or pi/4), the same can happen for the binary representations. In those cases, you have to stop the calculation when you reach your desired precision.

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

Sidebar

Related Questions

I have a basic question about assembly. Why do we bother doing arithmetic operations
Doing a custom Tumblr theme that will have a mix of the usual Tumblr
Doing a Google search I found several command-line SCEP clients that I can download
I have an element that can have an arbitrary background colour (set via a
in general i will use expr inside shell scripts for doing arithmetic operations. is
I am doing a puzzle where I have to deal with numbers of order
If I have a vector containing a number of unsorted files, how can I
I am doing lots of matrix arithmetic and would like to take advantage of
Possible Duplicate: void * arithmetic Hi guys I have a small question regarding pointer
I've been doing some performance testing, mainly so I can understand the difference between

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.