# How to get full float number expression?

**URL:** <https://discourse.processing.org/t/how-to-get-full-float-number-expression/24859>\
**Category:** Beginners\
**Created:** [October 23, 2020, 7:56pm UTC](https://discourse.processing.org/t/how-to-get-full-float-number-expression/24859 "2020-10-23T19:56:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duhovny](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@Duhovny](https://discourse.processing.org/u/Duhovny)\
**Post date:** [October 23, 2020, 7:56pm UTC](https://discourse.processing.org/t/how-to-get-full-float-number-expression/24859/1 "2020-10-23T19:56:29Z")

</div>

Hello, first post here from me!

I am a beginner in real programming, had some visual scripting experience as a hobby. I have a general question about floating point representation.

I tested some things and found that a maximum number of digits in a fractional part of a float number is 9 when dealing with long fractional numbers, meaning there is a cutoff from 9th digit after the floating point, so the rounding error is significant.

If, for example, I use reciprocal function 1/x, precision is lost: 1/119 returns 0.008403362, but 1/0.008403362 returns 118.99999. In 32 bit standard, there should be more digits, as stated here:

“The smallest normal value of a float, known as FLT\_MIN, is 2-126. A significand of 24 1s starting at the place of the smallest normal power of two exponent (-126) is this 24 significant bit number:

1.11111111111111111111111 x 2-126

Written out longhand in binary it is 149 bits, 125 leading zeros followed by 24 1s. In decimal it is

0.00000000000000000000000000000000000002350988561514728583455765982071533026645717985517980855365926236850006129930346077117064851336181163787841796875

It has **149 digits** , 37 leading zeros followed by **112 significant digits.**"

source: https://www.exploringbinary.com/maximum-number-of-decimal-digits-in-binary-floating-point-numbers/

My questions are: How to get full expression of a float number as described above and use it in functions? Is there a limitation or restriction on long float numbers in processing? And, if there are restrictions, is it possible to work around them?

I searched for answers in processing forums and documentation without much results. So, I would very much appreciate if someone has more insight into this matter.

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 24, 2020, 4:50pm UTC](https://discourse.processing.org/t/how-to-get-full-float-number-expression/24859/2 "2020-10-24T16:50:07Z")

</div>

Hello,

My brief exploration into this…

```auto
import java.math.*;

BigDecimal a = new BigDecimal("0.00000000000000000000000000000000000002350988561514728583455765982071533026645717985517980855365926236850006129930346077117064851336181163787841796875");
//System.out.println(a);

BigDecimal b = a;
BigDecimal c = a.add(b);

System.out.println(a);
System.out.println(b);
System.out.println(c);

System.out.println(c.floatValue());
System.out.println(c.doubleValue());

```

References:

_[https://www.simplexacode.ch/en/blog/2018/07/using-bigdecimal-as-an-accurate-replacement-for-floating-point-numbers/](https://www.simplexacode.ch/en/blog/2018/07/using-bigdecimal-as-an-accurate-replacement-for-floating-point-numbers/)_

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e75e00ef824efb2607740edd1a6fef27f4b0c6a3.png)

`:)`
