To long

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

Shandy N. wrote:

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.