Bug 10887 - Both left and right shift of BigInteger are buggy
Summary: Both left and right shift of BigInteger are buggy
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-03-04 15:47 UTC by gentlebeldin
Modified: 2013-06-10 18:37 UTC (History)
2 users (show)

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


Attachments
Demo of the bug (506 bytes, text/x-csharp)
2013-03-04 15:47 UTC, gentlebeldin
Details


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 GitHub or Developer Community 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 gentlebeldin 2013-03-04 15:47:17 UTC
Created attachment 3533 [details]
Demo of the bug

Both << and >> of a BigInteger may give incorrect results, if the BigInteger occupies more than one uint, and the shift is a multiple of 32. The bug is shown by a simple program I'll attach: a left shift of 32 bits, followed by division by Pow(2, 32), should leave a number unchanged, and also a multiplication by Pow(2, 32), followed by a right shift of 32 bits. 
The bug shows up both in Mono 2.10.8.1 (Debian 2.10.8.1-1ubuntu2.2) and in Mono JIT compiler version 2.10.11 (mono-2-10/2baeee2 Wed Jan 16 16:40:16 EST 2013) on my iMac.
Comment 1 Rodrigo Kumpera 2013-06-10 18:37:02 UTC
Thanks for the test case. This has been fixed on mono 3.0 and will be part of the next release there.