# Regarding obtaining a number

**URL:** <https://discourse.nodered.org/t/regarding-obtaining-a-number/20906>\
**Category:** Dashboard\
**Created:** [27 January 2020 10:32 UTC](https://discourse.nodered.org/t/regarding-obtaining-a-number/20906 "2020-01-27T10:32:57Z")\
**Posts on this page:** 2\
**Page:** 3

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [31 January 2020 22:14 UTC](https://discourse.nodered.org/t/regarding-obtaining-a-number/20906/42 "2020-01-31T22:14:21Z")

</div>

> [@jatin.pachisia1](#):
>
> Invalid JSONata expression: Unable to cast value to a number: "\n00384290470000000010\r\n"

The reason for that exception is that your string has newline characters in it...  
you can remove those with the `$trim(payload)` function -- which strips off any leading and/or trailing whitespace characters.

But as Colin said, converting this long string of numbers to a numeric datatype using `$number()` will cause you to lose any leading 0's, and possibly some of the trailing significant digits...

E.g. `$trim("\n00384290470000000010\r\n").$number()` returns  
the numeric value `384290470000000000`

---

<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:** [1 March 2020 22:14 UTC](https://discourse.nodered.org/t/regarding-obtaining-a-number/20906/43 "2020-03-01T22:14:24Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/regarding-obtaining-a-number/20906.md?page=2)
