Bug 12580 - BigInteger + Bit shifting
Summary: BigInteger + Bit shifting
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.3.x
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-06-06 13:39 UTC by Boris Scheiman
Modified: 2013-06-10 17:45 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Boris Scheiman 2013-06-06 13:39:46 UTC
It seems that the current mono code for BigInteger / operator>> (probably even <<) is bugged. For instance:


Code:

var bi = BigInteger.Parse("230794411440927908251127453634");
Console.WriteLine(bi);
var bi2 = bi >> 32;
Console.WriteLine("bi >> 32: " + bi2);

var bi3 = bi;

for (int i = 0; i < 32; i++)
    bi3 >>= 1;

Console.WriteLine("bi >> 32 for: " + bi3);

Output: 

2013-06-06 12:37:34.042 Tests[29073:c07] 230794411440927908251127453634
2013-06-06 12:37:34.046 Tests[29073:c07] bi >> 32: 53736011371418479095
2013-06-06 12:37:34.047 Tests[29073:c07] bi >> 32 for: 53736011367507257557

bi >> 32 generates an incorrect value, whereas looping >> 1 returns the correct value. .NET confirms this.
Comment 1 Sebastien Pouliot 2013-06-07 14:33:10 UTC
Confirmed. It seems the DLR code has changed a lot since it was imported / tweaked.
http://dlr.codeplex.com/SourceControl/latest#991244

c.c. Rodrigo who has extensive history with the code ;-)
Comment 2 Rodrigo Kumpera 2013-06-10 17:45:46 UTC
This works with master.