[Ironruby-core] IronRuby and System::Decimal

Ben Hall ben2004uk at googlemail.com
Thu Nov 6 19:44:57 EST 2008


Also, how would I compare decimals in ruby, as Ruby doesn't have a
decimal type built in?

I wanted to do something like

@d > '12312.123123'.to_d

However, that doesn't appear to be possible.  I attempt to do to_f,
but I got the following error:
ArgumentError: Object must be of type Decimal.

>From mscorlib:0:in
`CompareTo'E:\IronRuby\r156\src\IronRuby.Libraries\Extensions\IComparableOps.cs:24:in
`<=>'

Any ideas?

Thanks
Ben


On Fri, Nov 7, 2008 at 12:20 AM, Ben Hall <ben2004uk at googlemail.com> wrote:
> Hello,
>
> Just playing around with some .Net interop and the Decimal type. When
> I do puts, I expected that this would have given me the underlying
> number, or at least call to_string.
>
> Instead I got the following behaviour, with the object type being outputted.
>
>>>> @d = System::Decimal.MinValue
> => #<System::Decimal:0x000005c>
>>>> puts @d
> #<System::Decimal:0x000005e>
> => nil
>>>> puts @d.to_string
> -79228162514264337593543950335
> => nil
>
> Is this by design?
>
> Thanks
>
> Ben
>


More information about the Ironruby-core mailing list