Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sk_sarkar
Level 7

String to Integer conversion

Hi, facing a problem here in core part of brightscript. like, str = "1234567891000" , and @console typing print str.toInt() and getting Output as 2147483647 though type Integer. Why? :?:
0 Kudos
4 Replies
Komag
Level 10

Re: String to Integer conversion

I've been blinded! :shock: 8-) Please use more normal colors, better for our eyes.

As to the problem, I can't help, sorry
0 Kudos
NewManLiving
Level 7

Re: String to Integer conversion

Your conversion has exceeded the maximum size of an integer, being the value it has returned.
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
mramim
Level 9

Re: String to Integer conversion

not sure why i remained stuck on this for a long time but you can call toInt() function on your strings to convert strings to int.

Reference:

https://developer.roku.com/docs/references/brightscript/interfaces/ifstringops.md#toint-as-integer

0 Kudos
sanity-check
Level 9

Re: String to Integer conversion

It's too big to be an int - BS has a 'long' but there's no "toLong" method.

Weirdly this works:

parseJson("1234567891000")

...that'll return a numeric value of type 'LongInteger'

 

[edit]Oh wow, only just noticed this is a thread dredged up from 2015, oops.

0 Kudos