# Delete the decimal places

**URL:** <https://discourse.nodered.org/t/delete-the-decimal-places/88274>\
**Category:** General\
**Created:** [26 May 2024 08:38 UTC](https://discourse.nodered.org/t/delete-the-decimal-places/88274 "2024-05-26T08:38:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [26 May 2024 08:38 UTC](https://discourse.nodered.org/t/delete-the-decimal-places/88274/1 "2024-05-26T08:38:51Z")

</div>

Hello!  
I would like to delete the decimal places on a number?  
Whats the best way to do this?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [26 May 2024 09:00 UTC](https://discourse.nodered.org/t/delete-the-decimal-places/88274/2 "2024-05-26T09:00:43Z")

</div>

For what reason?  
Do you require a string returned or a number  
Is the input a number or a string?  
Best to provide examples of input and required output.

---

<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:** [26 May 2024 09:01 UTC](https://discourse.nodered.org/t/delete-the-decimal-places/88274/3 "2024-05-26T09:01:40Z")

</div>

It depends what you want to do with it. If you are formatting it for display then, if for example it is in msg.payload, in a function node  
`msg.payload = msg.payload.toFixed(0)`  
will convert it to a string containing the nearest integer. However, if you want to keep using it as a number then  
`msg.payload = Math.floor(msg.payload)`  
will convert it to the integer below the number, or  
`msg.payload = Math.round(msg.payload)`  
will convert it to the nearest integer.

---

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [26 May 2024 12:25 UTC](https://discourse.nodered.org/t/delete-the-decimal-places/88274/4 "2024-05-26T12:25:59Z")

</div>

Hello!

Thanks for the answer. This is exactly what I was looking for.

---

<div class="post-metadata">

**Author:** ![elbertelena](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/elbertelena/32/91270_2.png) [@elbertelena](https://discourse.nodered.org/u/elbertelena)\
**Post date:** [28 May 2024 10:29 UTC](https://discourse.nodered.org/t/delete-the-decimal-places/88274/5 "2024-05-28T10:29:34Z")

</div>

Hello @madmax  
Why are you delete the decimal places ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 August 2024 10:29 UTC](https://discourse.nodered.org/t/delete-the-decimal-places/88274/6 "2024-08-26T10:29:44Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
