Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sk_sarkar
Visitor

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 4
Komag
Roku Guru

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
Visitor

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
Streaming Star

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
Roku Guru

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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.