# How to print with 2 decimals?

**URL:** <https://discourse.processing.org/t/how-to-print-with-2-decimals/13929>\
**Category:** Beginners\
**Created:** [September 11, 2019, 1:43pm UTC](https://discourse.processing.org/t/how-to-print-with-2-decimals/13929 "2019-09-11T13:43:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GuilhermeVolker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/guilhermevolker/32/5657_2.png) [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Post date:** [September 11, 2019, 1:43pm UTC](https://discourse.processing.org/t/how-to-print-with-2-decimals/13929/1 "2019-09-11T13:43:12Z")

</div>

Hello.  
I need to print a float variable with 2 decimals. I couldn’t find on processing reference 😑

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [September 11, 2019, 1:48pm UTC](https://discourse.processing.org/t/how-to-print-with-2-decimals/13929/2 "2019-09-11T13:48:21Z")

</div>

with the  
[https://processing.org/reference/nf\_.html](https://processing.org/reference/nf_.html)  
can say how many decimals you want show in a string

```auto
println( nf( 0.1234567,0,2) );

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [September 11, 2019, 6:43pm UTC](https://discourse.processing.org/t/how-to-print-with-2-decimals/13929/3 "2019-09-11T18:43:50Z")

</div>

Not your fault – the reference documentation for nf is actually misleading here.

For further examples and past discussion, also see:

- [https://forum.processing.org/two/discussion/23814/limiting-floating-numbers-to-2-decimal-places](https://forum.processing.org/two/discussion/23814/limiting-floating-numbers-to-2-decimal-places)

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [September 11, 2019, 7:24pm UTC](https://discourse.processing.org/t/how-to-print-with-2-decimals/13929/4 "2019-09-11T19:24:57Z")

</div>

…proposed an update to the reference to help answer this perennial question.

> <https://github.com/processing/processing-docs/pull/775/commits/06c73398c5caf09731721847490acb15c3428972>

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [September 12, 2019, 2:04am UTC](https://discourse.processing.org/t/how-to-print-with-2-decimals/13929/5 "2019-09-12T02:04:13Z")

</div>

and for the reference page i have 2 more ideas

-a- i like the header menu from the  
[https://p5js.org/reference/](https://p5js.org/reference/)  
so you could just jump directly to the “String Functions” group.

-b- HTML has some more features now,  
how about show some “tool tip” when you are over the link?

 ![html_tooltip_for_processing_refrence](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/76ca561d1bbef5164dc6bc86dcd2220dcc207117.png)

because, if you NOT know the command **nf()**

- how can you find it
- why you should click on it.
