# How to compare char with num

**URL:** <https://discourse.nodered.org/t/how-to-compare-char-with-num/81452>\
**Category:** General\
**Tags:** function-node\
**Created:** [20 September 2023 12:07 UTC](https://discourse.nodered.org/t/how-to-compare-char-with-num/81452 "2023-09-20T12:07:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gideon](https://avatars.discourse-cdn.com/v4/letter/g/7ba0ec/32.png) [@gideon](https://discourse.nodered.org/u/gideon)\
**Post date:** [20 September 2023 12:07 UTC](https://discourse.nodered.org/t/how-to-compare-char-with-num/81452/1 "2023-09-20T12:07:21Z")

</div>

I get a message from a serial port every second.  
The message is text like "8\r\n" and I need to ask if it over then 55 .  
I only look at the number like here 8.  
The problem is that I try to compare char with a number and it doesn't work.  
how can I solve this.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [20 September 2023 12:30 UTC](https://discourse.nodered.org/t/how-to-compare-char-with-num/81452/2 "2023-09-20T12:30:03Z")

</div>

Hi @gideon

Make sure the `Split input` is set correctly on the serial node, then you can do  
`parseInt(msg.payload) > 55` where necessary

You might need to verify you are getting true integers, and not hex values however.

---

<div class="post-metadata">

**Author:** ![gideon](https://avatars.discourse-cdn.com/v4/letter/g/7ba0ec/32.png) [@gideon](https://discourse.nodered.org/u/gideon)\
**Post date:** [20 September 2023 12:38 UTC](https://discourse.nodered.org/t/how-to-compare-char-with-num/81452/3 "2023-09-20T12:38:36Z")

</div>

> [@marcus-j-davies](#):
>
> parseInt(msg.payload)

thanks you marcus 😁

---

<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:** [4 October 2023 12:38 UTC](https://discourse.nodered.org/t/how-to-compare-char-with-num/81452/4 "2023-10-04T12:38:59Z")

</div>

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