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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:30:16+00:00 2026-06-18T21:30:16+00:00

Is it possible to create a decimal value that is perfectly precise? On my

  • 0

Is it possible to create a decimal value that is perfectly precise?

On my computer, an integer value in C++ is 32 bits, and a long/double/long long are 64 bits. It is my belief, and correct me if this is wrong, that a floating point value has in the first part, a 1.xxxxx... multiplied by a mantissa. So in there you have a decimal, and the part after the 1 is a decimal value.

Therefore, would it be possible or has it been done, to simply “plop” 2 integers together and make a decimal value that is completely precise?

You would have then a maximum value of 4294967295.4294967295 or 2147483647.4294967295 for a signed value (the decimal would not need to be signed).

Has this been done before? If so why is it not popular in comparison to doubles and floats?

  • 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-18T21:30:17+00:00Added an answer on June 18, 2026 at 9:30 pm

    Yes and no

    The short answer is that a variation on your proposal is used all the time for manipulating perfectly precise decimal strings. It’s not a native format for any popular computer so it is handled in software, but that hardly matters given the CPU speed these days. The key is to store the fraction as a base 10 decimal string.

    Now, your proposal appears to be suggesting fixed point numbers with the binary decimal point in between bits 32 and 33. This has also been done, but it doesn’t solve the problem of decimal string fractions being unrepresentable.

    You see, the problem is that a decimal string fraction is a rational number of the form x / (2n * 5m) and most of such values are not representable in a binary fraction which represents only x / 2n.

    So, for example, between .01 and .99, only .25, .50, and .75 have exact binary representations. This is true of both IEEE floating point and of your fixed point proposal.

    Now, if instead of a binary fixed point, you simply scale numbers by some power of 10, then all of your numbers will be exact. So, if your scale was 106, then $123.45 would be stored as 123450000.

    That is, you have two choices. Because all whole numbers have an exact representation in either binary or decimal, you can either not store fractions, and simply scale as noted above, or you can store fractions, but do it internally with decimal digits. Say, allocate 4 bits per digit. This format is called BCD.

    All of these techniques have been implemented countless times, so you don’t really have to do it yourself. Look at, for example, BigDecimal in Ruby.

    If we were to redo civilization all over again, it might be convenient to pick a number base that is a power of two. All of these problems stem directly from the way we write fractional values IRL. We use decimal strings, which are mostly impossible to precisely represent as binary fractions.

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

Sidebar

Related Questions

is it possible to create a custom NaN value in Python? I know a
Is it possible to create a table with a column that combines two column
Is there a way in .NET to create a type derived from decimal that
Is it possible to create a plot from List(Of Decimal) values in Excel with
Is possible create something like this without using ActionBar? I just need button which
Possible Duplicate: Truncate (not round) decimal places in SQL Server Can't figure this out.
Is possible create an extension for SQL Management Studio in Visual Studio 2010? Visual
Hi it'd like to know if it's at all possible create a parametric equalizer
Possible Duplicate: Create provisioning profile in iphone application i developed my iphone app and
Possible Duplicate: Create event handler for OnScroll for web browser control I would like

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.