# Ds18b20 only one or two digits

**URL:** https://discourse.nodered.org/t/ds18b20-only-one-or-two-digits/15172
**Category:** General
**Created:** [5 September 2019 19:54 UTC](https://discourse.nodered.org/t/ds18b20-only-one-or-two-digits/15172 "2019-09-05T19:54:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![RudiRuessel](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@RudiRuessel](https://discourse.nodered.org/u/RudiRuessel)
#### Post date: [5 September 2019 19:54 UTC](https://discourse.nodered.org/t/ds18b20-only-one-or-two-digits/15172/1 "2019-09-05T19:54:40Z")

</div>

Hello, is it possible to get my temperature values with only one or two fractional digits? For example with a funktion node?

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [5 September 2019 20:00 UTC](https://discourse.nodered.org/t/ds18b20-only-one-or-two-digits/15172/2 "2019-09-05T20:00:26Z")

</div>

Do you know JavaScript? That's what the function node uses and it is certainly possible in JS to do this, there are lots of examples on the Internet.

I think you could also do it with a change node and JSONata (`$round(123.456, 2) => 123.46`). You could probably even do it with a change node and a regex 🤓

> **[Numeric functions · JSONata](http://docs.jsonata.org/numeric-functions#round)**
>
> \## \`$number()\`

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 September 2019 20:14 UTC](https://discourse.nodered.org/t/ds18b20-only-one-or-two-digits/15172/3 "2019-09-05T20:14:20Z")

</div>

Usually it is best to do that at the point where you display it. Don't throw away resolution before you need to. For example in a node-red dashboard you can put something like this in the value format field to display it with two decimal places  
`{{msg.payload | number:2}}`

---

<div class="post-metadata">

### Author: ![RudiRuessel](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@RudiRuessel](https://discourse.nodered.org/u/RudiRuessel)
#### Post date: [5 September 2019 20:19 UTC](https://discourse.nodered.org/t/ds18b20-only-one-or-two-digits/15172/4 "2019-09-05T20:19:23Z")

</div>

Thank you!

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [5 September 2019 21:35 UTC](https://discourse.nodered.org/t/ds18b20-only-one-or-two-digits/15172/5 "2019-09-05T21:35:08Z")

</div>

I think that should be `{{value | number: 2}}`
