to long

S

Shandy Nantz

I am trying to convert some vb script code to its Ruby counterpart and
there is a function in the script which converts an expression to a long
data type and my question is, is there a way to do the same thing in
Ruby. I had been using to_i but I'm not sure if that is correct. Thanks,

-S
 
M

Mark Bush

Shandy said:
I am trying to convert some vb script code to its Ruby counterpart and
there is a function in the script which converts an expression to a long
data type and my question is, is there a way to do the same thing in
Ruby. I had been using to_i but I'm not sure if that is correct. Thanks,

Depends what your "expression" is. In Ruby, there's no need to worry
about how big an integer is. Different subclasses of Integer are used
to handle integers of different magnitudes, but that is transparent, so:

a = "123".to_i
=> 123
a.class
=> Fixnum

a = "248578913250896781364890374857878134".to_i
=> 248578913250896781364890374857878134
a.class
=> Bignum

Remember that the variable is just a name pointing to an object and can
point to any object of any class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top