# C programmers - float accuracy

**URL:** <https://boards.straightdope.com/t/c-programmers-float-accuracy/356393>\
**Category:** Factual Questions\
**Created:** [May 11, 2006, 5:27pm UTC](https://boards.straightdope.com/t/c-programmers-float-accuracy/356393 "2006-05-11T17:27:36Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![ZenBeam](https://avatars.discourse-cdn.com/v4/letter/z/3ab097/32.png) [@ZenBeam](https://boards.straightdope.com/u/ZenBeam)\
**Post date:** [May 12, 2006, 5:33pm UTC](https://boards.straightdope.com/t/c-programmers-float-accuracy/356393/21 "2006-05-12T17:33:31Z")

</div>

> [@](#):
>
> The option to read it as a string in the first place is not available to me. I need to check the decimal value against the configured maximum number of decimal places.

I don’t see how you’ll ever be able to do this. Even if the number you get is 0.5, you don’tknow the user didn’t enter 0.5000000000000000000234. And if you had a quad precision number, you wouldn’t know if the user entered 0.5000000000000000000000000000000000000000234.

---

<div class="post-metadata">

**Author:** ![Polerius](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Polerius](https://boards.straightdope.com/u/Polerius)\
**Post date:** [May 12, 2006, 8:32pm UTC](https://boards.straightdope.com/t/c-programmers-float-accuracy/356393/22 "2006-05-12T20:32:03Z")

</div>

> [@cmkeller](#):
>
> The option to read it as a string in the first place is not available to me. I need to check the decimal value against the configured maximum number of decimal places.

I don’t know how much control you have over this, but can you make the user enter two values, one for the integer portion, and one for the fractional portion?  
e.g. on a form, you could have two boxes side-by-side, separated by a .  
and then you could check how large the fractional portion was

e.g. the user would see something like:  
Enetr value: [999].[99]

[Previous page](https://boards.straightdope.com/t/c-programmers-float-accuracy/356393.md?page=1)
