Here is a patch for the rest of the number stuff. The main patch
(NumericBits.patch) modifies the following files:
Numeric.cs: minor fixes and documentation
FixnumOps.cs and BignumOps.cs: minor fixes and improvements
FloatOps.cs: complete implementation
Integer.cs: complete implementation (I know Jb Evain beat me to it on the
upto/downto front but I hope that, without stealing his thunder, this is a
complete implantation of the methods).
Precision.cs: complete implementation
LibrarySites.cs: Added a couple of extra sites and fixed a bug with abs
site.
Of course you have to regenerate Initializer.Generated.cs to get it to
compile.
I have also added a file (BignumLiteral.patch) which "turns on"the Bignum
literal in IronRuby. It affects the following files:
BigInteger.cs: Adds a new Create method
Tokenizer.cs : Calls the BigInteger.Create method.
I appreciate that this is not going to get included in the build but I
thought I would provide it for people who want to get into Bignums (or get
most of the specs to actually run) before the official fix for this is
released.
To keep things simple I have not added the many unit tests (specs) that I
have written for these classes, even though these have probably taken 75% of
the time spent. This is because the old builtin specs are being deprecated
and it seems more sensible to try and push these specs into the Rubinius
test suite instead. Hopefully Charles Nutter will be pleased!
Finally if you do run the specs there will be a number of failures:
The match method has not yet been defined so any specs that check for
runtime type or version number will fail.
I believe that these are primarily due to issues with the
Ruby.Runtime.Converter class and Ruby.Runtime.StringFormatter. I will push
through bug reports on RubyForge for these soon.
There are also some issues with IronRuby throwing FloatDomainError where
CRuby throws RangeError. I have not convinced myself whether this is an
issue inside Protocols or FloatOps so I have left them as they are for now.
Ironically, FloatDomainError derives from RangeError so it would not make
much difference in a real application anyway.
By the way, there is an interesting issue with Float#to_s. It appears that
on Windows you get an extra zero in the exponent in both CRuby and IronRuby,
which given the Rubinius specs doesn't appear on other platforms: 1.4e046
rather than 1.4e46.
Finally, all the Rubinius specs think that 0x40000000 is a Bignum but in
IronRuby (and JRuby) this is Fixnum. Therefore most of the bignum specs
are actually testing against Fixnum instead of Bignum. So the Bignum
functionality is not being given a work-out and more annoyingly, where there
are different semantics between Fixnum and Bignum, the specs fail (i.e.
Fixnum#div vs Bignum#div).
Looking forward to the feedback.
Regards,
Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20080118/ad9599a7/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BignumLiteral.patch
Type: application/octet-stream
Size: 2505 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/ironruby-core/attachments/20080118/ad9599a7/attachment-0002.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NumericBits.patch
Type: application/octet-stream
Size: 104578 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/ironruby-core/attachments/20080118/ad9599a7/attachment-0003.obj